Yimaru-BackEnd/internal/repository/lms_user_progress_snapshot_test.go

42 lines
872 B
Go

package repository
import (
"testing"
"github.com/jackc/pgx/v5/pgtype"
)
func TestPgInt8IDsToInt64ReturnsEmptySlice(t *testing.T) {
got := pgInt8IDsToInt64(nil)
if got == nil {
t.Fatal("expected empty slice, got nil")
}
if len(got) != 0 {
t.Fatalf("expected empty slice, got len=%d", len(got))
}
}
func TestPgInt8IDsToInt64FiltersInvalidIDs(t *testing.T) {
got := pgInt8IDsToInt64([]pgtype.Int8{
{Int64: 10, Valid: true},
{Valid: false},
{Int64: 20, Valid: true},
})
if len(got) != 2 {
t.Fatalf("expected 2 ids, got %d", len(got))
}
if got[0] != 10 || got[1] != 20 {
t.Fatalf("unexpected ids: %#v", got)
}
}
func TestInt64IDsOrEmptyReturnsEmptySlice(t *testing.T) {
got := int64IDsOrEmpty(nil)
if got == nil {
t.Fatal("expected empty slice, got nil")
}
if len(got) != 0 {
t.Fatalf("expected empty slice, got len=%d", len(got))
}
}