MCPcopy Index your code
hub / github.com/perkeep/perkeep / TestGenerateClientConfig

Function TestGenerateClientConfig

pkg/serverinit/serverinit_test.go:426–459  ·  view source on GitHub ↗

TestGenerateClientConfig validates the client config generated for display by the HelpHandler.

(t *testing.T)

Source from the content-addressed store, hash-verified

424// TestGenerateClientConfig validates the client config generated for display
425// by the HelpHandler.
426func TestGenerateClientConfig(t *testing.T) {
427 inName := filepath.Join("testdata", "gen_client_config.in")
428 wantName := strings.Replace(inName, ".in", ".out", 1)
429
430 b, err := replaceRingPath(inName)
431 if err != nil {
432 t.Fatalf("Failed to read high-level server config file: %v", err)
433 }
434 b = backslashEscape(b)
435 var hiLevelConf serverconfig.Config
436 if err := json.Unmarshal(b, &hiLevelConf); err != nil {
437 t.Fatalf("Failed to unmarshal server config: %v", err)
438 }
439 lowLevelConf, err := serverinit.GenLowLevelConfig(&hiLevelConf)
440 if err != nil {
441 t.Fatalf("Failed to generate low-level config: %v", err)
442 }
443 generatedConf, err := clientconfig.GenerateClientConfig(lowLevelConf.Export_Obj())
444 if err != nil {
445 t.Fatalf("Failed to generate client config: %v", err)
446 }
447
448 wb, err := replaceRingPath(wantName)
449 if err != nil {
450 t.Fatalf("Failed to read want config file: %v", err)
451 }
452 wb = backslashEscape(wb)
453 var wantConf clientconfig.Config
454 if err := json.Unmarshal(wb, &wantConf); err != nil {
455 t.Fatalf("Failed to unmarshall want config: %v", err)
456 }
457
458 compareConfigurations(t, inName, generatedConf, wantConf)
459}
460
461// TestConfigHandlerRedaction validates that configHandler redacts sensitive
462// values, still resulting in a valid JSON document.

Callers

nothing calls this directly

Calls 6

GenerateClientConfigFunction · 0.92
replaceRingPathFunction · 0.85
backslashEscapeFunction · 0.85
compareConfigurationsFunction · 0.85
Export_ObjMethod · 0.80
FatalfMethod · 0.65

Tested by

no test coverage detected