test(11-07): pin that a keyless Typesense engine is never configured
- TestSyncEngineRegistration: the typesense import registers the driver and a missing or blank api_key reports Configured false, the gate that keeps beachcomber from sending anything
This commit is contained in:
@@ -338,3 +338,32 @@ func TestEngineConfig(t *testing.T) {
|
||||
t.Fatal("unwrapURLError changed a plain error")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSyncEngineRegistration covers the engine side of the sync gates
|
||||
// (T-11-25): importing the package registers "typesense" for
|
||||
// search.driver, and without search.typesense.api_key the engine reports
|
||||
// itself unconfigured, which is what makes beachcomber skip every sync
|
||||
// before any request.
|
||||
func TestSyncEngineRegistration(t *testing.T) {
|
||||
cfg, err := compass.Open(compass.Options{Dir: t.TempDir(), Env: "testing", Environ: []string{}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := cfg.Set("search.driver", "typesense"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
svc, err := beachcomber.From(backpack.New(cfg))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e, ok := svc.Engine().(*Engine)
|
||||
if !ok || e.Configured() {
|
||||
t.Fatalf("engine without an API key = %#v, want an unconfigured *typesense.Engine", svc.Engine())
|
||||
}
|
||||
if err := cfg.Set("search.typesense.api_key", " "); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if LoadConfig(cfg).APIKey != "" || New(LoadConfig(cfg)).Configured() {
|
||||
t.Fatal("a blank API key counts as configured")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user