feat: format and add test
This commit is contained in:
28
client/cards_test.go
Normal file
28
client/cards_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user