|
1 | 1 | package mcp |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "slices" |
4 | 5 | "testing" |
5 | 6 | ) |
6 | 7 |
|
@@ -58,20 +59,22 @@ func TestFlagSetParse(t *testing.T) { |
58 | 59 | t.Fatalf("vars from buildArgFlagSet should not be empty") |
59 | 60 | } |
60 | 61 |
|
61 | | - args := []string{"-repos=A", "-repos=B", "-count=10", "-boolFlag", "-tag=testTag"} |
| 62 | + args := []string{"-repos=A", "-repos=B", `-repos=["repo1", "repo2"]`, "-count=10", "-boolFlag", "-tag=testTag"} |
62 | 63 |
|
63 | 64 | if err := flagSet.Parse(args); err != nil { |
64 | 65 | t.Fatalf("flagset parsing failed: %v", err) |
65 | 66 | } |
66 | 67 | DerefFlagValues(flagSet, vars) |
67 | 68 |
|
68 | | - if v, ok := vars["repos"].([]string); ok { |
69 | | - if len(v) != 2 { |
70 | | - t.Fatalf("expected flag 'repos' values to have length %d but got %d", 2, len(v)) |
71 | | - } |
72 | | - } else { |
73 | | - t.Fatalf("expected flag 'repos' to have type of []string but got %T", v) |
| 69 | + expectedRepos := []string{"A", "B", "repo1", "repo2"} |
| 70 | + actualRepos, ok := vars["repos"].([]string) |
| 71 | + if !ok { |
| 72 | + t.Fatalf("failed to cast repos to []string, got %T", actualRepos) |
74 | 73 | } |
| 74 | + if !slices.Equal(expectedRepos, actualRepos) { |
| 75 | + t.Fatalf("expected repos %v, got %v", expectedRepos, vars["repos"]) |
| 76 | + } |
| 77 | + |
75 | 78 | if v, ok := vars["tag"].(string); ok { |
76 | 79 | if v != "testTag" { |
77 | 80 | t.Fatalf("expected flag 'tag' values to have value %q but got %q", "testTag", v) |
|
0 commit comments