Dan Anglin
73547c49c6
Add a new Identity type with the required methods so that now the board types (Card, Status and soon Tag) can automatically satisfy the BoltItem interface.
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|