More tests!
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Hamcha 2019-06-28 16:29:19 +02:00
parent 6c6a8a843d
commit fcb265c490

View file

@ -118,7 +118,7 @@ func TestDraftSessionButEverythingGoesWrong(t *testing.T) {
// Try creating a new session as NOT the owner
mock.message("test-guest", "create", draft.SessionOptions{
Players: 8, // Two players, six bots
Players: 8,
Options: draft.DraftOptions{
Type: draft.DraftSet,
Positioning: draft.PosEven,
@ -128,12 +128,66 @@ func TestDraftSessionButEverythingGoesWrong(t *testing.T) {
})
mock.expect(t, "must-be-owner", 5)
//TODO:
// Try to start session when session doesn't exist
// Try to create session twice
// Try to start session with no players
// Try to start session as not the owner
// Try to make too many players join a session
// Try creating a session with an invalid type
mock.message("test-owner", "create", draft.SessionOptions{
Players: 8,
Options: draft.DraftOptions{
Type: "lolwhat",
},
})
mock.expect(t, "session-create-error", 5)
// Try creating a session with invalid data
mock.message("test-owner", "create", 42)
mock.expect(t, "invalid-data", 5)
// Try starting a session that doesn't exist
mock.message("test-owner", "start", nil)
mock.expect(t, "command-unavailable", 5)
// Try creating the session twice
mock.message("test-owner", "create", draft.SessionOptions{
Players: 2,
Options: draft.DraftOptions{
Type: draft.DraftSet,
Positioning: draft.PosEven,
Set: mlp.SetAbsoluteDiscord,
PackCount: 4,
},
})
mock.expect(t, "session-open", 5)
mock.message("test-owner", "create", draft.SessionOptions{
Players: 2,
Options: draft.DraftOptions{
Type: draft.DraftSet,
Positioning: draft.PosEven,
Set: mlp.SetAbsoluteDiscord,
PackCount: 4,
},
})
mock.expect(t, "command-unavailable", 5)
// Try to start session when no-one has joined
mock.message("test-owner", "start", nil)
mock.expect(t, "session-start-error", 5)
// Try to make too many players join
mock.message("a", "join", nil)
mock.expect(t, "player-joined-session", 5)
mock.message("b", "join", nil)
mock.expect(t, "player-joined-session", 5)
mock.message("c", "join", nil)
mock.expect(t, "session-full", 5)
// Try to make someone join a session that already started
mock.message("test-owner", "start", nil)
mock.multiexpect(t, 5, "session-start", "draft-order")
mock.message("c", "join", nil)
mock.expect(t, "session-already-started", 5)
//TODO More picking, etc shenanigans
}
func (m *MockServer) expect(t *testing.T, typ string, timeout int) {
@ -183,7 +237,6 @@ func (m *MockServer) multiexpect(t *testing.T, timeout int, types ...string) {
// Oh noes
t.Fatalf("Expected one of %s but got \"%s\"", types, msg.Message.Type)
}
return
case <-time.After(time.Duration(timeout) * time.Second):
t.Fatalf("Expected one of %s but found nothing (timeout after %d seconds)!", types, timeout)
}