Files
any2anexoj/internal/ephemeral_store_test.go
T
natercioandnatercio 9bd4230ff1
Badges / coveralls (push) Successful in 1m4s
Internal state persistence (#27)
Allow us to generate year over year reports without having to rerun everything from the beginning.

Co-authored-by: Natercio Moniz <[email protected]>
2026-08-03 00:33:06 +01:00

48 lines
1.2 KiB
Go

package internal_test
import (
"testing"
"github.com/nmoniz/any2anexoj/internal"
)
// Verify that EphemeralStore.Load returns a non-nil empty map and no error.
func TestEphemeralStore_Load(t *testing.T) {
store := internal.EphemeralStore{}
queues, err := store.Load(t.Context())
if err != nil {
t.Fatalf("Load returned unexpected error: %v", err)
}
if queues == nil {
t.Fatalf("Load returned a nil map; expected an empty map")
}
if len(queues) != 0 {
t.Fatalf("Load returned %d entries; expected 0", len(queues))
}
}
// Verify that EphemeralStore.Save accepts a queue map without error and
// discards its contents.
func TestEphemeralStore_Save(t *testing.T) {
store := internal.EphemeralStore{}
var q internal.FillerQueue
err := store.Save(t.Context(), map[string]*internal.FillerQueue{
"TEST": &q,
})
if err != nil {
t.Fatalf("Save returned unexpected error: %v", err)
}
// Save is a no-op, so a subsequent Load must still be empty.
queues, err := store.Load(t.Context())
if err != nil {
t.Fatalf("Load after Save returned unexpected error: %v", err)
}
if len(queues) != 0 {
t.Fatalf("Load after Save returned %d entries; expected 0", len(queues))
}
}