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
Player Tracking Go SDK Conformance Tests #1527
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,37 @@ func main() { | |
if c != capacity { | ||
log.Fatalf("Player Capacity should be %d, but is %d", capacity, c) | ||
} | ||
|
||
playerID := "1234" | ||
if ok, err := sdk.Alpha().PlayerConnect(playerID); err != nil { | ||
log.Fatalf("Error registering player as connected: %s", err) | ||
} else if !ok { | ||
log.Fatalf("PlayerConnect returned false") | ||
} | ||
|
||
if ok, err := sdk.Alpha().IsPlayerConnected(playerID); err != nil { | ||
log.Fatalf("Error checking if player is connected: %s", err) | ||
} else if !ok { | ||
log.Fatalf("IsPlayerConnected returned false") | ||
} | ||
|
||
if list, err := sdk.Alpha().GetConnectedPlayers(); err != nil { | ||
log.Fatalf("Error getting connected player: %s", err) | ||
} else if len(list) == 0 { | ||
log.Fatalf("No connected players returned") | ||
} | ||
|
||
if ok, err := sdk.Alpha().PlayerDisconnect(playerID); err != nil { | ||
log.Fatalf("Error registering player as disconnected: %s", err) | ||
} else if !ok { | ||
log.Fatalf("PlayerDisconnect returned false") | ||
} | ||
|
||
if c, err = sdk.Alpha().GetPlayerCount(); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it would work, but it would be nice to call this once with the player connected (and verify that result is 1) and then again here to check that it is back to 0. Similarly, it would be nice to verify that IsPlayerConnected returns false for a non-existent player and also that it returns false for "1234" after the player disconnects. I'm sure this is all covered by unit tests, but it would be nice to have it covered by the conformance tests as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely covered by the unit tests, but I can't see how we could do this with the current structure of the conformance tests. The conformance tests check that a method has been called once with a specific value, so there is no concept for ordering. @aLekSer unless you can think of anything I'm not thinking of? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I thought. I don't want to block this change, but let's file an issue so we can discuss if it would be worth modifying the conformance test infra. |
||
log.Fatalf("Error retrieving player count: %s", err) | ||
} else if c != int64(0) { | ||
log.Fatalf("Player Count should be 0, but is %d", c) | ||
} | ||
} | ||
|
||
err = sdk.Shutdown() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like these don't have to be in the same order as the code. do we just check that they were all called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it doesn't matter the order they are called in - it checks that SDK methods are called with the expected arguments.