Skip to content

Commit

Permalink
Also get public-value from the database.
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbollen committed Oct 18, 2023
1 parent 4d81ea4 commit 50943f7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions features/lobbies.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Feature: Lobby Discovery

When "green" requests all lobbies
Then "green" should have received only these lobbies
| code | playerCount |
| dhgp75mn2bll | 1 |
| code | playerCount | public |
| dhgp75mn2bll | 1 | true |



Expand Down
8 changes: 6 additions & 2 deletions features/support/steps/network.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { After, DataTable, Given, Then, When } from '@cucumber/cucumber'
import assert from 'assert'
import { World } from '../world'

After(async function (this: World) {
Expand Down Expand Up @@ -178,7 +177,12 @@ Then('{string} should have received only these lobbies', function (this: World,
delete lobby[key]
}
})
assert.notStrictEqual(lobby, row)
const want = row as any
Object.keys(row).forEach(key => {
if (`${lobby[key] as string}` !== `${want[key] as string}`) {
throw new Error(`expected ${key} to be ${want[key] as string} but got ${lobby[key] as string}`)
}
})
})
if (player.lastReceivedLobbies.length !== expectedLobbies.hashes().length) {
throw new Error(`expected ${expectedLobbies.hashes().length} lobbies but got ${player.lastReceivedLobbies.length}`)
Expand Down
4 changes: 2 additions & 2 deletions internal/signaling/stores/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (s *PostgresStore) ListLobbies(ctx context.Context, game, filter string) ([

var lobbies []Lobby
rows, err := s.DB.Query(ctx, `
SELECT code, peers, meta
SELECT code, peers, public, meta
FROM lobbies
WHERE game = $1
AND public = true
Expand All @@ -294,7 +294,7 @@ func (s *PostgresStore) ListLobbies(ctx context.Context, game, filter string) ([
for rows.Next() {
var lobby Lobby
var peers []string
err = rows.Scan(&lobby.Code, &peers, &lobby.CustomData)
err = rows.Scan(&lobby.Code, &peers, &lobby.Public, &lobby.CustomData)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 50943f7

Please sign in to comment.