2024-01-23 18:31:01 +00:00
|
|
|
package board_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"codeflow.dananglin.me.uk/apollo/pelican/internal/board"
|
|
|
|
)
|
|
|
|
|
2024-01-23 19:42:35 +00:00
|
|
|
func TestSetInvalidID(t *testing.T) {
|
|
|
|
identity := board.Identity{
|
|
|
|
ID: -1,
|
2024-01-23 18:31:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-23 19:42:35 +00:00
|
|
|
err := identity.SetID(-1000)
|
2024-01-23 18:31:01 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
case err == nil:
|
|
|
|
t.Errorf("%s\tWanted an error for setting an invalid card ID; got 'nil' instead.", failure)
|
|
|
|
case errors.As(err, &board.InvalidIDError{}):
|
|
|
|
t.Logf("%s\tGot expected error after attempting to set an invalid card ID; got '%v'", success, err)
|
|
|
|
default:
|
|
|
|
t.Errorf("%s\tGot unexpected error after attempting to set an invalid card ID; got '%v'", failure, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCardSetExistingID(t *testing.T) {
|
2024-01-23 19:42:35 +00:00
|
|
|
identity := board.Identity{
|
|
|
|
ID: 5,
|
2024-01-23 18:31:01 +00:00
|
|
|
}
|
|
|
|
|
2024-01-23 19:42:35 +00:00
|
|
|
err := identity.SetID(10)
|
2024-01-23 18:31:01 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
case err == nil:
|
|
|
|
t.Errorf("%s\tWanted an error for setting a card ID that's already been set; got 'nil' instead.", failure)
|
|
|
|
case errors.As(err, &board.IDAlreadySetError{}):
|
|
|
|
t.Logf("%s\tGot expected error after attempting to set a card ID that's already been set; got '%v'", success, err)
|
|
|
|
default:
|
|
|
|
t.Errorf("%s\tGot unexpected error after attempting to set a card ID that's already been set; got '%v'", failure, err)
|
|
|
|
}
|
|
|
|
}
|