MCPcopy
hub / github.com/perkeep/perkeep / TestConfigHandlerRemoveKnownKeys

Function TestConfigHandlerRemoveKnownKeys

pkg/serverinit/serverinit_test.go:489–508  ·  view source on GitHub ↗

TestConfigHandlerRemoveKnownKeys validates that configHandler removes "_knownkeys" keys properly, still resulting in a valid JSON document.

(t *testing.T)

Source from the content-addressed store, hash-verified

487// TestConfigHandlerRemoveKnownKeys validates that configHandler removes
488// "_knownkeys" keys properly, still resulting in a valid JSON document.
489func TestConfigHandlerRemoveKnownKeys(t *testing.T) {
490 config := serverinit.ExportNewConfigFromObj(jsonconfig.Obj{
491 "/ui/": "",
492 "_knownkeys": map[string]string{
493 "key": "value",
494 },
495 })
496
497 rr := httptest.NewRecorder()
498 serverinit.ConfigHandler(config).ServeHTTP(rr, nil)
499 got := make(map[string]string)
500 if err := json.Unmarshal(rr.Body.Bytes(), &got); err != nil {
501 t.Fatalf("Failed to unmarshal configHandler response: %v", err)
502 }
503 want := map[string]string{
504 "/ui/": "",
505 }
506
507 compareConfigurations(t, "configHandlerRemoveKnownKeys", got, want)
508}

Callers

nothing calls this directly

Calls 5

ExportNewConfigFromObjFunction · 0.92
ConfigHandlerFunction · 0.92
compareConfigurationsFunction · 0.85
FatalfMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected