package mila import ( "context" "path/filepath" "testing" ) func TestFileStorePersistsAndLoadsState(t *testing.T) { path := filepath.Join(t.TempDir(), "bvk_content.json") ctx := context.Background() first := NewFileStore(path) state := ContentState{ Route: "3", Text: "Гостиный двор", Template: "main", } if err := first.Set(ctx, state); err != nil { t.Fatalf("set state: %v", err) } second := NewFileStore(path) got, err := second.Get(ctx) if err != nil { t.Fatalf("get state: %v", err) } if got.Route != state.Route || got.Text != state.Text || got.Template != state.Template { t.Fatalf("unexpected state: %+v", got) } if got.UpdatedAt.IsZero() != state.UpdatedAt.IsZero() { t.Fatalf("unexpected updated_at value: %s", got.UpdatedAt) } } func TestFileStoreMissingFileReturnsNotReady(t *testing.T) { store := NewFileStore(filepath.Join(t.TempDir(), "missing.json")) _, err := store.Get(context.Background()) if err == nil { t.Fatal("expected error") } if err != ErrNotReady { t.Fatalf("expected ErrNotReady, got %v", err) } }