|
6 | 6 | from ots_containers.commands.instance._helpers import ( |
7 | 7 | for_each_instance, |
8 | 8 | format_command, |
| 9 | + format_journalctl_hint, |
9 | 10 | resolve_identifiers, |
10 | 11 | ) |
11 | 12 | from ots_containers.commands.instance.annotations import InstanceType |
12 | 13 |
|
13 | 14 |
|
| 15 | +class TestFormatJournalctlHint: |
| 16 | + """Test format_journalctl_hint helper.""" |
| 17 | + |
| 18 | + def test_single_web_instance(self): |
| 19 | + """Should generate journalctl command for single web instance.""" |
| 20 | + instances = {InstanceType.WEB: ["7043"]} |
| 21 | + result = format_journalctl_hint(instances) |
| 22 | + assert result == "journalctl -t onetime-web-7043 -f" |
| 23 | + |
| 24 | + def test_multiple_web_instances(self): |
| 25 | + """Should generate journalctl command for multiple web instances.""" |
| 26 | + instances = {InstanceType.WEB: ["7043", "7044"]} |
| 27 | + result = format_journalctl_hint(instances) |
| 28 | + assert result == "journalctl -t onetime-web-7043 -t onetime-web-7044 -f" |
| 29 | + |
| 30 | + def test_mixed_instance_types(self): |
| 31 | + """Should generate journalctl command for mixed instance types.""" |
| 32 | + instances = { |
| 33 | + InstanceType.WEB: ["7043"], |
| 34 | + InstanceType.WORKER: ["billing"], |
| 35 | + InstanceType.SCHEDULER: ["main"], |
| 36 | + } |
| 37 | + result = format_journalctl_hint(instances) |
| 38 | + assert "-t onetime-web-7043" in result |
| 39 | + assert "-t onetime-worker-billing" in result |
| 40 | + assert "-t onetime-scheduler-main" in result |
| 41 | + assert result.endswith(" -f") |
| 42 | + |
| 43 | + def test_empty_instances(self): |
| 44 | + """Should return empty string for empty instances.""" |
| 45 | + result = format_journalctl_hint({}) |
| 46 | + assert result == "" |
| 47 | + |
| 48 | + def test_worker_instance(self): |
| 49 | + """Should generate journalctl command for worker instance.""" |
| 50 | + instances = {InstanceType.WORKER: ["1"]} |
| 51 | + result = format_journalctl_hint(instances) |
| 52 | + assert result == "journalctl -t onetime-worker-1 -f" |
| 53 | + |
| 54 | + |
14 | 55 | class TestFormatCommand: |
15 | 56 | """Test format_command helper.""" |
16 | 57 |
|
|
0 commit comments