Files
wehub-resource-sync a06f331eb8
install-script / powershell-syntax (push) Waiting to run
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
install-script / install (macos-14) (push) Waiting to run
install-script / install (ubuntu-latest) (push) Waiting to run
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:33:42 +08:00

52 lines
1.4 KiB
Go

package serverstack
import (
"path/filepath"
"testing"
"go.uber.org/zap"
"github.com/zzet/gortex/internal/graph"
)
// TestOpenBackend_MemoryDefault asserts the memory backend (and the empty
// default) returns a usable in-process store.
func TestOpenBackend_MemoryDefault(t *testing.T) {
for _, name := range []string{"", "memory", "mem", "in-memory"} {
store, cleanup, err := OpenBackend(name, "", 0, zap.NewNop(), false)
if err != nil {
t.Fatalf("OpenBackend(%q): %v", name, err)
}
if store == nil {
t.Fatalf("OpenBackend(%q): nil store", name)
}
if _, ok := store.(*graph.Graph); !ok {
t.Errorf("OpenBackend(%q): want *graph.Graph, got %T", name, store)
}
cleanup()
}
}
// TestOpenBackend_SqliteOpensFile asserts the sqlite backend opens (and
// creates) a store at the resolved path.
func TestOpenBackend_SqliteOpensFile(t *testing.T) {
path := filepath.Join(t.TempDir(), "store.sqlite")
store, cleanup, err := OpenBackend("sqlite", path, 0, zap.NewNop(), true)
if err != nil {
t.Fatalf("OpenBackend(sqlite): %v", err)
}
if store == nil {
t.Fatal("nil sqlite store")
}
cleanup()
}
// TestOpenBackend_Unknown asserts only memory|sqlite are accepted — a
// stale backend name (e.g. the removed ladybug) errors rather than
// silently falling back.
func TestOpenBackend_Unknown(t *testing.T) {
if _, _, err := OpenBackend("ladybug", "", 0, zap.NewNop(), false); err == nil {
t.Fatal("an unknown backend must error")
}
}