@@ -62,31 +62,38 @@ func assertInstanceRedis(t *testing.T, client *redis.Client, expectedInstance *g
6262func TestRedisInstanceStorage_UpsertInstance (t * testing.T ) {
6363 client := test .GetRedisConnection (t , redisAddress )
6464 storage := NewRedisInstanceStorage (client , 0 )
65- instance := & game_room.Instance {
66- ID : "1" ,
67- SchedulerID : "game" ,
68- Status : game_room.InstanceStatus {
69- Type : game_room .InstancePending ,
70- },
71- }
65+ t .Run ("should succeed" , func (t * testing.T ) {
66+ instance := & game_room.Instance {
67+ ID : "1" ,
68+ SchedulerID : "game" ,
69+ Status : game_room.InstanceStatus {
70+ Type : game_room .InstancePending ,
71+ },
72+ }
73+
74+ require .NoError (t , storage .UpsertInstance (context .Background (), instance ))
75+ assertInstanceRedis (t , client , instance )
7276
73- require .NoError (t , storage .UpsertInstance (context .Background (), instance ))
74- assertInstanceRedis (t , client , instance )
75-
76- instance .Status .Type = game_room .InstanceReady
77- instance .Address = & game_room.Address {
78- Host : "host" ,
79- Ports : []game_room.Port {
80- {
81- Name : "game" ,
82- Port : 7000 ,
83- Protocol : "udp" ,
77+ instance .Status .Type = game_room .InstanceReady
78+ instance .Address = & game_room.Address {
79+ Host : "host" ,
80+ Ports : []game_room.Port {
81+ {
82+ Name : "game" ,
83+ Port : 7000 ,
84+ Protocol : "udp" ,
85+ },
8486 },
85- },
86- }
87+ }
8788
88- require .NoError (t , storage .UpsertInstance (context .Background (), instance ))
89- assertInstanceRedis (t , client , instance )
89+ require .NoError (t , storage .UpsertInstance (context .Background (), instance ))
90+ assertInstanceRedis (t , client , instance )
91+ })
92+
93+ t .Run ("should fail - instance is nil" , func (t * testing.T ) {
94+ err := storage .UpsertInstance (context .Background (), nil )
95+ require .Error (t , err )
96+ })
9097}
9198
9299func TestRedisInstanceStorage_GetInstance (t * testing.T ) {
0 commit comments