Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Some documentation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
weiiwang01 committed Apr 3, 2024
1 parent 11c10fb commit 9bd80c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions paas_app_charmer/_gunicorn/logrotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
It will be injected into the container and does not depend on non-standard libraries.
"""

import argparse
import datetime
import glob
import os

# this script runs similarly to a shell script, disable the warning for using subprocess
import subprocess # nosec B404
import time

Expand Down
15 changes: 15 additions & 0 deletions tests/unit/flask/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,24 @@ def test_log_rotate(tmp_path):
files = list(tmp_path.iterdir())
assert len(files) == 1
archive = files[0]
# if the filename doesn't match the pattern, a ValueError will be raised here
datetime.datetime.strptime(archive.name, "access-%Y-%m-%d-%H-%M-%S.log")


def test_log_rotate_not_rotated(tmp_path):
"""
arrange: create a small log file
act: run the log rotate function
assert: the log file should not be rotated
"""
log_file = tmp_path / "access.log"
log_file.touch()
assert not logrotate.rotate(str(log_file.absolute()))
assert log_file.exists()
files = list(tmp_path.iterdir())
assert len(files) == 1


def test_log_rotate_cleanup(tmp_path):
"""
arrange: create a log file larger than the max log file size, along with many archive files
Expand Down

0 comments on commit 9bd80c2

Please # to comment.