@@ -11,17 +11,62 @@ assert_output_contains() {
11
11
run ./gh-workflow-log-cleaner
12
12
[ " $status " -eq 0 ]
13
13
expected_output=" Usage:
14
- gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>]
14
+ gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]
15
+
16
+ Options:
17
+ -h, --help Show this help message and exit
18
+ --limit Limit the number of runs to delete (default: 1000)
19
+
20
+ Available workflows:
21
+ setup active 114854128
22
+ test active 114855097"
23
+ [ " $output " = " $expected_output " ]
24
+ }
25
+
26
+ @test " with help option" {
27
+ run ./gh-workflow-log-cleaner --help
28
+ [ " $status " -eq 0 ]
29
+ expected_output=" Usage:
30
+ gh workflow-log-cleaner [<workflow-id> | <workflow-name> | <filename>] [options]
31
+
32
+ Options:
33
+ -h, --help Show this help message and exit
34
+ --limit Limit the number of runs to delete (default: 1000)
15
35
16
36
Available workflows:
17
37
setup active 114854128
18
38
test active 114855097"
19
39
[ " $output " = " $expected_output " ]
20
40
}
21
41
22
- @test " with a workflow-name parameter " {
23
- run ./gh-workflow-log-cleaner setup
42
+ @test " with a workflow-name and limit option " {
43
+ run ./gh-workflow-log-cleaner setup --limit 1
24
44
[ " $status " -eq 0 ]
25
45
assert_output_contains " Deleting run ID:"
26
46
assert_output_contains " ✓ Request to delete workflow submitted."
27
47
}
48
+
49
+ @test " with limit option and a workflow-name" {
50
+ run ./gh-workflow-log-cleaner --limit 1 setup
51
+ [ " $status " -eq 0 ]
52
+ assert_output_contains " Deleting run ID:"
53
+ assert_output_contains " ✓ Request to delete workflow submitted."
54
+ }
55
+
56
+ @test " with an invalid option" {
57
+ run ./gh-workflow-log-cleaner setup --invalid
58
+ [ " $status " -eq 1 ]
59
+ assert_output_contains " Unknown option: --invalid"
60
+ }
61
+
62
+ @test " without a workflow" {
63
+ run ./gh-workflow-log-cleaner --limit 1
64
+ [ " $status " -eq 1 ]
65
+ assert_output_contains " Error: Specify a workflow to delete the log"
66
+ }
67
+
68
+ @test " with an invalid workflow-name" {
69
+ run ./gh-workflow-log-cleaner invalid
70
+ [ " $status " -eq 0 ]
71
+ assert_output_contains " could not find any workflows named invalid"
72
+ }
0 commit comments