MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestURLOverrideDoesNotPersist

Function TestURLOverrideDoesNotPersist

internal/config/config_test.go:721–748  ·  view source on GitHub ↗

TestURLOverrideDoesNotPersist: a CODEHAMR_URL override lives in cfg.URLOverride and ActiveURL reflects it, but Save writes only the stored URL, so re-bootstrapping without the env var restores the original endpoint.

(t *testing.T)

Source from the content-addressed store, hash-verified

719// cfg.URLOverride and ActiveURL reflects it, but Save writes only the stored
720// URL, so re-bootstrapping without the env var restores the original endpoint.
721func TestURLOverrideDoesNotPersist(t *testing.T) {
722 dir := t.TempDir()
723 cfg, _, err := Bootstrap(dir)
724 if err != nil {
725 t.Fatal(err)
726 }
727 originalURL := cfg.ActiveProfile().URL
728 cfg.URLOverride = "http://override:9999"
729 if got := cfg.ActiveURL(); got != "http://override:9999" {
730 t.Fatalf("ActiveURL() ignored override: %q", got)
731 }
732 if got := cfg.ActiveProfile().URL; got != originalURL {
733 t.Fatalf("override leaked into stored profile: %q", got)
734 }
735 if err := cfg.Save(); err != nil {
736 t.Fatal(err)
737 }
738 reloaded, _, err := Bootstrap(dir)
739 if err != nil {
740 t.Fatal(err)
741 }
742 if reloaded.ActiveProfile().URL != originalURL {
743 t.Fatalf("Save persisted the override: %q", reloaded.ActiveProfile().URL)
744 }
745 if reloaded.URLOverride != "" {
746 t.Fatalf("URLOverride round-tripped through YAML: %q", reloaded.URLOverride)
747 }
748}
749
750// TestSaveTightensPreexistingLoosePerms covers the upgrade path fresh-bootstrap
751// misses: a config.yaml from an older world-readable codehamr (or a hand-edit)

Callers

nothing calls this directly

Calls 4

BootstrapFunction · 0.85
ActiveProfileMethod · 0.80
ActiveURLMethod · 0.80
SaveMethod · 0.80

Tested by

no test coverage detected