From a146f39ed183f9957f659505b74782a84e5183c0 Mon Sep 17 00:00:00 2001 From: Max Resnick Date: Mon, 26 May 2025 00:48:20 -0700 Subject: fix: make sure basePath is set if it's a fresh install --- internal/admin/service_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/admin/service_test.go') diff --git a/internal/admin/service_test.go b/internal/admin/service_test.go index 9af6bb9..2cf4e0d 100644 --- a/internal/admin/service_test.go +++ b/internal/admin/service_test.go @@ -88,6 +88,27 @@ func TestInitServer(t *testing.T) { destModelFile, destPolicyFile, destConfigFile := tempModelPolicyConfig(t, tempDir, tempRepoDir) + t.Run("test default config basePath", func(t *testing.T) { + // Create a new temporary directory for this test + testRepoDir := t.TempDir() + + // Create a service with mgmtRepo=true to trigger the default config path + svc, err := NewService(destModelFile, + destPolicyFile, + "gitserver.yaml", // Non-existent file to trigger default config + testRepoDir, + true) + + if err != nil { + t.Fatalf("Failed to create service: %v", err) + } + + // Verify that basePath was correctly set in the default config + if svc.Conf.basePath != testRepoDir { + t.Errorf("Expected basePath to be %q, got %q", testRepoDir, svc.Conf.basePath) + } + }) + t.Run("test reload config success", func(t *testing.T) { svc, _ := NewService(destModelFile, destPolicyFile, -- cgit v1.2.3