Skip to content

Commit

Permalink
fix: Sort results in command builder before comparing (#4385)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemassa authored Mar 26, 2024
1 parent 566b15f commit e846d90
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions server/events/project_command_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package events_test
import (
"os"
"path/filepath"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -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",
},
},
},
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e846d90

Please sign in to comment.