Skip to content

Commit d5a6714

Browse files
authored
chore: Add better assert condition for a flaky test (#27)
* chore: Add better assert condition for a flaky test This particular test was flaky as the loadToolset runs an iteration through the map of Tools and the map iteration order is intentionally randomized. This assert condition will correctly catch the error even if the map iteration order is random. * minor fix * Update client_test.go
1 parent c4ef3d8 commit d5a6714

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core/client_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,16 @@ func TestLoadToolAndLoadToolset(t *testing.T) {
334334
t.Fatal("Expected an error for unused auth token in strict mode, but got nil")
335335
}
336336
// In strict mode, the error is reported for the first tool it doesn't apply to
337-
if !strings.Contains(err.Error(), "validation failed for tool") {
337+
// Since the order of tools in a map is non deterministic
338+
// we will check for errors fro both tools.
339+
errStr := err.Error()
340+
isToolAError := strings.Contains(errStr, "validation failed for tool 'toolA'") &&
341+
strings.Contains(errStr, "unused-auth") &&
342+
strings.Contains(errStr, "github")
343+
344+
isToolBError := strings.Contains(errStr, "no parameter named 'param1' found on tool 'toolB'")
345+
346+
if !(isToolAError || isToolBError) {
338347
t.Errorf("Incorrect error for unused auth token in strict mode. Got: %v", err)
339348
}
340349
})

0 commit comments

Comments
 (0)