-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_test.go
More file actions
57 lines (52 loc) · 1.44 KB
/
main_test.go
File metadata and controls
57 lines (52 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"strings"
"testing"
)
func TestParseOptionsDebugUnsafeImpliesDebug(t *testing.T) {
opts, err := parseOptions([]string{"--debug-unsafe"})
if err != nil {
t.Fatalf("parseOptions: %v", err)
}
if !opts.debug {
t.Fatal("expected --debug-unsafe to enable debug logging")
}
if !opts.debugUnsafe {
t.Fatal("expected debugUnsafe to be set")
}
}
func TestParseOptionsHelpAndVersionAliases(t *testing.T) {
opts, err := parseOptions([]string{"-h", "-v"})
if err != nil {
t.Fatalf("parseOptions: %v", err)
}
if !opts.showHelp {
t.Fatal("expected -h to enable help")
}
if !opts.showVersion {
t.Fatal("expected -v to enable version")
}
}
func TestParseOptionsRejectsUnexpectedArgs(t *testing.T) {
if _, err := parseOptions([]string{"unexpected"}); err == nil {
t.Fatal("expected parseOptions to reject positional args")
}
}
func TestHelpTextDocumentsSafeAndUnsafeDebug(t *testing.T) {
help := helpText()
if !strings.Contains(help, "--debug") {
t.Fatal("expected help to mention --debug")
}
if !strings.Contains(help, "--debug-unsafe") {
t.Fatal("expected help to mention --debug-unsafe")
}
if strings.Contains(help, "/tmp/atria-debug.log") {
t.Fatal("expected help to not mention the old /tmp debug path")
}
if !strings.Contains(help, "debug.log") {
t.Fatal("expected help to mention debug.log")
}
if !strings.Contains(help, "may capture secrets") {
t.Fatal("expected help to warn about unsafe logging")
}
}