29 lines
582 B
Go
29 lines
582 B
Go
package client
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetCardByID(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
cardID string
|
|
wantErr bool
|
|
wantCard *Card
|
|
}{
|
|
{"valid card", "xy1-1", false, &Card{ID: "xy1-1"}},
|
|
{"invalid card", "invalid-id", true, nil},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
card, err := GetCardByID(tt.cardID)
|
|
|
|
require.ErrorIs(t, err, ErrNotFound)
|
|
require.Equal(t, tt.wantCard, card, "expected card: %v, got: %v for cardID %v", tt.wantCard, card, tt.cardID)
|
|
})
|
|
}
|
|
}
|