build spotify-to-navidrome migrator with recovery flow
This commit is contained in:
42
internal/session/session_test.go
Normal file
42
internal/session/session_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSaveLoadRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
path := filepath.Join(t.TempDir(), "session.json")
|
||||
in := Data{
|
||||
Spotify: SpotifyState{
|
||||
ClientID: "abc123",
|
||||
AccessToken: "access-token",
|
||||
RefreshToken: "refresh-token",
|
||||
ExpiresAt: "2026-01-02T03:04:05Z",
|
||||
},
|
||||
}
|
||||
|
||||
if err := Save(path, in); err != nil {
|
||||
t.Fatalf("Save failed: %v", err)
|
||||
}
|
||||
|
||||
out, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatalf("Load failed: %v", err)
|
||||
}
|
||||
|
||||
if out.Spotify.ClientID != in.Spotify.ClientID {
|
||||
t.Fatalf("ClientID mismatch: got %q want %q", out.Spotify.ClientID, in.Spotify.ClientID)
|
||||
}
|
||||
if out.Spotify.AccessToken != in.Spotify.AccessToken {
|
||||
t.Fatalf("AccessToken mismatch")
|
||||
}
|
||||
if out.Spotify.RefreshToken != in.Spotify.RefreshToken {
|
||||
t.Fatalf("RefreshToken mismatch")
|
||||
}
|
||||
if out.Spotify.ExpiresAt != in.Spotify.ExpiresAt {
|
||||
t.Fatalf("ExpiresAt mismatch: got %q want %q", out.Spotify.ExpiresAt, in.Spotify.ExpiresAt)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user