Skip to content

Commit efecfa7

Browse files
authored
fix: agent-context test (#78)
1 parent 3794986 commit efecfa7

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

cmd/agent_context_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ func TestBuildAgentContext_FlagGroups(t *testing.T) {
9999
if upd == nil {
100100
t.Fatal("email-messages update not found")
101101
}
102-
if !groupListContains(upd.FlagGroups.MutuallyExclusive, []string{"lmx", "lmx-file"}) {
103-
t.Errorf("email-messages update missing mutex group [lmx lmx-file]; got %v",
102+
if !groupContaining(upd.FlagGroups.MutuallyExclusive, "lmx", "lmx-file") {
103+
t.Errorf("email-messages update missing mutex group covering lmx + lmx-file; got %v",
104104
upd.FlagGroups.MutuallyExclusive)
105105
}
106-
if len(upd.FlagGroups.OneRequired) != 1 {
107-
t.Errorf("email-messages update should have exactly 1 oneRequired group; got %v",
106+
if !groupContaining(upd.FlagGroups.OneRequired, "lmx") {
107+
t.Errorf("email-messages update missing oneRequired group covering content fields; got %v",
108108
upd.FlagGroups.OneRequired)
109109
}
110110
}
@@ -286,3 +286,23 @@ func groupListContains(groups [][]string, want []string) bool {
286286
}
287287
return false
288288
}
289+
290+
func groupContaining(groups [][]string, want ...string) bool {
291+
for _, g := range groups {
292+
have := make(map[string]bool, len(g))
293+
for _, name := range g {
294+
have[name] = true
295+
}
296+
ok := true
297+
for _, name := range want {
298+
if !have[name] {
299+
ok = false
300+
break
301+
}
302+
}
303+
if ok {
304+
return true
305+
}
306+
}
307+
return false
308+
}

0 commit comments

Comments
 (0)