fix: Sort results in command builder before comparing (#4385)

This commit is contained in:
Luke Massa
2024-03-26 15:09:29 -04:00
committed by GitHub
parent 566b15f356
commit e846d90d1a

View File

@@ -3,6 +3,7 @@ package events_test
import (
"os"
"path/filepath"
"sort"
"strings"
"testing"
@@ -195,13 +196,13 @@ terraform {
exp: []expCtxFields{
{
ProjectName: "",
RepoRelDir: "work",
Workspace: "test-workspace1",
RepoRelDir: "test",
Workspace: "test-workspace12",
},
{
ProjectName: "",
RepoRelDir: "test",
Workspace: "test-workspace12",
RepoRelDir: "work",
Workspace: "test-workspace1",
},
},
},
@@ -286,6 +287,17 @@ terraform {
})
Ok(t, err)
Equals(t, len(c.exp), len(ctxs))
// Sort so comparisons are deterministic
sort.Slice(ctxs, func(i, j int) bool {
if ctxs[i].ProjectName != ctxs[j].ProjectName {
return ctxs[i].ProjectName < ctxs[j].ProjectName
}
if ctxs[i].RepoRelDir != ctxs[j].RepoRelDir {
return ctxs[i].RepoRelDir < ctxs[j].RepoRelDir
}
return ctxs[i].Workspace < ctxs[j].Workspace
})
for i, actCtx := range ctxs {
expCtx := c.exp[i]
Equals(t, expCtx.ProjectName, actCtx.ProjectName)