mirror of
https://git.sr.ht/~joren/streamrip-go
synced 2026-06-17 15:05:39 +02:00
initial Go port of streamrip
This commit is contained in:
42
internal/store/sqlite_test.go
Normal file
42
internal/store/sqlite_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSQLiteStore(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
path := filepath.Join(t.TempDir(), "test.db")
|
||||
|
||||
s, err := NewSQLite(path)
|
||||
if err != nil {
|
||||
t.Fatalf("NewSQLite() error = %v", err)
|
||||
}
|
||||
defer func() { _ = s.Close() }()
|
||||
|
||||
ok, err := s.IsDownloaded(ctx, "a")
|
||||
if err != nil {
|
||||
t.Fatalf("IsDownloaded() error = %v", err)
|
||||
}
|
||||
if ok {
|
||||
t.Fatalf("expected not downloaded")
|
||||
}
|
||||
|
||||
if err = s.MarkDownloaded(ctx, "a"); err != nil {
|
||||
t.Fatalf("MarkDownloaded() error = %v", err)
|
||||
}
|
||||
|
||||
ok, err = s.IsDownloaded(ctx, "a")
|
||||
if err != nil {
|
||||
t.Fatalf("IsDownloaded() error = %v", err)
|
||||
}
|
||||
if !ok {
|
||||
t.Fatalf("expected downloaded")
|
||||
}
|
||||
|
||||
if err = s.MarkFailed(ctx, "qobuz", "track", "1"); err != nil {
|
||||
t.Fatalf("MarkFailed() error = %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user