Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
import (
"os"
"path/filepath"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -195,13 +196,13 @@
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 @@
})
Ok(t, err)
Equals(t, len(c.exp), len(ctxs))

// Sort so comparisons are determinisitic

Check failure on line 291 in server/events/project_command_builder_test.go

View workflow job for this annotation

GitHub Actions / Linting

`determinisitic` is a misspelling of `deterministic` (misspell)

Check failure on line 291 in server/events/project_command_builder_test.go

View workflow job for this annotation

GitHub Actions / Linting

[golangci-lint] reported by reviewdog 🐶 `determinisitic` is a misspelling of `deterministic` (misspell) Raw Output: server/events/project_command_builder_test.go:291:31: `determinisitic` is a misspelling of `deterministic` (misspell) // Sort so comparisons are determinisitic ^
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
Loading