pelican/internal/board/identity_test.go

43 lines
1.1 KiB
Go
Raw Normal View History

package board_test
import (
"errors"
"testing"
"codeflow.dananglin.me.uk/apollo/pelican/internal/board"
)
func TestSetInvalidID(t *testing.T) {
identity := board.Identity{
ID: -1,
}
err := identity.SetID(-1000)
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) {
identity := board.Identity{
ID: 5,
}
err := identity.SetID(10)
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)
}
}