diff options
Diffstat (limited to 'internal/admin/service_test.go')
| -rw-r--r-- | internal/admin/service_test.go | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/internal/admin/service_test.go b/internal/admin/service_test.go index 13a0007..06088bc 100644 --- a/internal/admin/service_test.go +++ b/internal/admin/service_test.go @@ -40,6 +40,28 @@ repos: `) ) +func tempModelPolicyConfig(t *testing.T, tempDir, tempRepoDir string) (string, string, string) { + + // auth model + destModelFile := filepath.Join(tempDir, "auth_model.ini") + srcModelFile := "../../auth_model.ini" + copyFile(t, srcModelFile, destModelFile) + // end auth model + + // policy + destPolicyFile := filepath.Join(tempDir, "testpolicy.csv") + srcPolicyFile := "../../tests/testpolicy.csv" + copyFile(t, srcPolicyFile, destPolicyFile) + // end policy + + // config + destConfigFile := filepath.Join(tempRepoDir, "gitserver.yaml") + srcConfigFile := "../../gitserver.yaml" + copyFile(t, srcConfigFile, destConfigFile) + // end config + return destModelFile, destPolicyFile, destConfigFile +} + func copyFile(t *testing.T, srcFilePath, destPath string) { srcFile, err := os.Open(srcFilePath) if err != nil { @@ -64,23 +86,7 @@ func TestInitServer(t *testing.T) { tempDir := t.TempDir() tempRepoDir := t.TempDir() - // auth model - destModelFile := filepath.Join(tempDir, "auth_model.ini") - srcModelFile := "../../auth_model.ini" - copyFile(t, srcModelFile, destModelFile) - // end auth model - - // policy - destPolicyFile := filepath.Join(tempDir, "testpolicy.csv") - srcPolicyFile := "../../tests/testpolicy.csv" - copyFile(t, srcPolicyFile, destPolicyFile) - // end policy - - // config - destConfigFile := filepath.Join(tempRepoDir, "gitserver.yaml") - srcConfigFile := "../../gitserver.yaml" - copyFile(t, srcConfigFile, destConfigFile) - // end config + destModelFile, destPolicyFile, destConfigFile := tempModelPolicyConfig(t, tempDir, tempRepoDir) t.Run("test reload config success", func(t *testing.T) { svc, _ := NewService(destModelFile, |