MCPcopy
hub / github.com/docker/compose / TestGetFlags

Function TestGetFlags

cmd/cmdtrace/cmd_span_test.go:29–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

27)
28
29func TestGetFlags(t *testing.T) {
30 // Initialize flagSet with flags
31 fs := flag.NewFlagSet("up", flag.ContinueOnError)
32 var (
33 detach string
34 timeout string
35 )
36 fs.StringVar(&detach, "detach", "d", "")
37 fs.StringVar(&timeout, "timeout", "t", "")
38 _ = fs.Set("detach", "detach")
39 _ = fs.Set("timeout", "timeout")
40
41 tests := []struct {
42 name string
43 input *flag.FlagSet
44 expected []string
45 }{
46 {
47 name: "NoFlags",
48 input: flag.NewFlagSet("NoFlags", flag.ContinueOnError),
49 expected: nil,
50 },
51 {
52 name: "Flags",
53 input: fs,
54 expected: []string{"detach", "timeout"},
55 },
56 }
57
58 for _, test := range tests {
59 t.Run(test.name, func(t *testing.T) {
60 result := getFlags(test.input)
61 if !reflect.DeepEqual(result, test.expected) {
62 t.Errorf("Expected %v, but got %v", test.expected, result)
63 }
64 })
65 }
66}
67
68func TestCommandName(t *testing.T) {
69 tests := []struct {

Callers

nothing calls this directly

Calls 1

getFlagsFunction · 0.85

Tested by

no test coverage detected