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

Implement node synthetic ref #108

Merged
merged 10 commits into from
Dec 23, 2022
Prev Previous commit
Next Next commit
Make patch sorting stable
  • Loading branch information
vassilvk committed Dec 23, 2022
commit ec1f6915930e8c2a7f2d3efcb15747ef68ea1d45
6 changes: 6 additions & 0 deletions core/dragnetwebhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"io/ioutil"
"path"
"sort"

"github.com/golang/mock/gomock"
"github.com/kubemod/kubemod/api/v1beta1"
Expand Down Expand Up @@ -108,6 +109,11 @@ var _ = Describe("DragnetWebhookHandler", func() {

Expect(len(response.Patches)).To(Equal(2))

// Sort the patch because the order returned by CalculatePatch is unstable.
sort.SliceStable(response.Patches, func(i, j int) bool {
return (response.Patches[i].Operation + response.Patches[i].Path) < (response.Patches[j].Operation + response.Patches[j].Path)
})

Expect(response.Patches[0].Operation).To(Equal("add"))
Expect(response.Patches[0].Path).To(Equal("/metadata/labels/topology.kubernetes.io~1region"))
Expect(response.Patches[0].Value).To(Equal("us-west-2"))
Expand Down