Skip to content

Commit

Permalink
refactor(allocation): Reimplement the Validate method using "field.Er…
Browse files Browse the repository at this point in the history
…rorList"

Signed-off-by: aimuz <mr.imuz@gmail.com>
  • Loading branch information
aimuz committed Jul 12, 2023
1 parent 405b0e2 commit d2bb1dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/crd-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func main() {
ctx := context.Background()
newGS, err := agonesClient.AgonesV1().GameServers(gs.Namespace).Create(ctx, gs, metav1.CreateOptions{})
if err != nil {
logrus.Fatal("Unable to create GameServer: %v", err)
logrus.Fatalf("Unable to create GameServer: %v", err)
}
logrus.Infof("New GameServer name is: %s", newGS.ObjectMeta.Name)

Expand Down
10 changes: 5 additions & 5 deletions pkg/gameserverallocations/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestAllocatorAllocate(t *testing.T) {
}}
gsa.ApplyDefaults()
errs := gsa.Validate()
require.Len(t, len(errs), 0)
require.Len(t, errs, 0)

gs, err := a.allocate(ctx, &gsa)
require.NoError(t, err)
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestAllocatorAllocatePriority(t *testing.T) {
}}
gsa.ApplyDefaults()
errs := gsa.Validate()
require.Len(t, len(errs), 0)
require.Len(t, errs, 0)

t.Run(name, func(t *testing.T) {
test(t, a, gsa.DeepCopy())
Expand Down Expand Up @@ -469,7 +469,7 @@ func TestAllocatorAllocateOnGameServerUpdateError(t *testing.T) {
// without converter we don't end up with at least one selector
gsa.Converter()
errs := gsa.Validate()
require.Len(t, len(errs), 0)
require.Len(t, errs, 0)
require.Len(t, gsa.Spec.Selectors, 1)

// try the private method
Expand Down Expand Up @@ -525,7 +525,7 @@ func TestAllocatorRunLocalAllocations(t *testing.T) {
}}
gsa.ApplyDefaults()
errs := gsa.Validate()
require.Len(t, len(errs), 0)
require.Len(t, errs, 0)

// line up 3 in a batch
j1 := request{gsa: gsa.DeepCopy(), response: make(chan response)}
Expand Down Expand Up @@ -582,7 +582,7 @@ func TestAllocatorRunLocalAllocations(t *testing.T) {
}}
gsa.ApplyDefaults()
errs := gsa.Validate()
require.Len(t, len(errs), 0)
require.Len(t, errs, 0)

j1 := request{gsa: gsa.DeepCopy(), response: make(chan response)}
a.pendingRequests <- j1
Expand Down

0 comments on commit d2bb1dc

Please sign in to comment.