Skip to content

Commit

Permalink
Adds copy of game server to TestSDKServerReserveTimeout patch reactor
Browse files Browse the repository at this point in the history
  • Loading branch information
igooch committed Apr 29, 2024
1 parent cb4ed30 commit 11c80d6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/sdkserver/sdkserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,23 +1023,24 @@ func TestSDKServerReserveTimeout(t *testing.T) {
gs.ApplyDefaults()

m.AgonesClient.AddReactor("list", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) {
return true, &agonesv1.GameServerList{Items: []agonesv1.GameServer{*gs.DeepCopy()}}, nil
return true, &agonesv1.GameServerList{Items: []agonesv1.GameServer{gs}}, nil
})

m.AgonesClient.AddReactor("patch", "gameservers", func(action k8stesting.Action) (bool, runtime.Object, error) {
pa := action.(k8stesting.PatchAction)
patchJSON := pa.GetPatch()
patch, err := jsonpatch.DecodePatch(patchJSON)
assert.NoError(t, err)
gsJSON, err := json.Marshal(gs)
gsCopy := gs.DeepCopy()
gsJSON, err := json.Marshal(gsCopy)
assert.NoError(t, err)
patchedGs, err := patch.Apply(gsJSON)
assert.NoError(t, err)
err = json.Unmarshal(patchedGs, &gs)
err = json.Unmarshal(patchedGs, &gsCopy)
assert.NoError(t, err)

state <- gs.Status
return true, &gs, nil
state <- gsCopy.Status
return true, gsCopy, nil
})

sc, err := defaultSidecar(m)
Expand Down

0 comments on commit 11c80d6

Please sign in to comment.