33 lines
788 B
Go
33 lines
788 B
Go
package service_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"watch-party-backend/internal/repo"
|
|
"watch-party-backend/internal/service"
|
|
)
|
|
|
|
type stubRepo struct {
|
|
current repo.Episode
|
|
err error
|
|
}
|
|
|
|
func (s stubRepo) GetCurrent(ctx context.Context) (repo.Episode, error) {
|
|
return s.current, s.err
|
|
}
|
|
|
|
func TestEpisodeService_GetCurrent(t *testing.T) {
|
|
want := repo.Episode{EpNum: 1, EpTitle: "Ep1", SeasonName: "S1", StartTime: "00:00:00", PlaybackLength: "00:24:00", DateCreated: time.Now()}
|
|
svc := service.NewEpisodeService(stubRepo{current: want})
|
|
|
|
got, err := svc.GetCurrent(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if got.EpNum != want.EpNum || got.EpTitle != want.EpTitle {
|
|
t.Fatalf("mismatch: got %+v want %+v", got, want)
|
|
}
|
|
}
|