diff options
| author | Max Resnick <max@ofmax.li> | 2024-05-04 10:24:48 -0700 |
|---|---|---|
| committer | Max Resnick <max@ofmax.li> | 2024-05-20 21:33:57 -0700 |
| commit | b8584fec70bd6810fa2392deadc69595b3e94cfa (patch) | |
| tree | 2c2b17e06f780ad7d6ba46a0189f4faf45629fcb /internal/admin/service_test.go | |
| parent | 11fe503d5ea17fa3ddc4ce2308ea82b6edc7763e (diff) | |
| download | go-git-server-b8584fec70bd6810fa2392deadc69595b3e94cfa.tar.gz | |
feat: refactor of repo management
Diffstat (limited to '')
| -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, |