summaryrefslogtreecommitdiffstats
path: root/integrations/git_helper_for_declarative_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-04-28 09:32:23 +0100
committerGitHub <noreply@github.com>2020-04-28 09:32:23 +0100
commit1f0b797ddc139c3241c9b9694f0666a28ab41d80 (patch)
treedc2341417062baf75e21bf48b91b3169b47a1a28 /integrations/git_helper_for_declarative_test.go
parentb0849abf3d9b25d06ab8099c62409d87d9a0ca86 (diff)
downloadgitea-1f0b797ddc139c3241c9b9694f0666a28ab41d80.tar.gz
gitea-1f0b797ddc139c3241c9b9694f0666a28ab41d80.zip
Make the PushCreate test declarative (#11229)
Reduce the code duplication in the PushCreate test and switch to a declarative format. * Instead of explicitly creating the repository re-use functions from the other declarative tests and add comments * Ensure that the test repository is deleted at the end of test * Slightly reorder the sub-tests Also reduce the code duplication in MergeFork and add some comments there too and make doGitCloneFail be self-contained. Signed-off-by: Andrew Thornton art27@cantab.net
Diffstat (limited to 'integrations/git_helper_for_declarative_test.go')
-rw-r--r--integrations/git_helper_for_declarative_test.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go
index 5838b9e512..13b3e92c14 100644
--- a/integrations/git_helper_for_declarative_test.go
+++ b/integrations/git_helper_for_declarative_test.go
@@ -115,10 +115,13 @@ func doGitClone(dstLocalPath string, u *url.URL) func(*testing.T) {
}
}
-func doGitCloneFail(dstLocalPath string, u *url.URL) func(*testing.T) {
+func doGitCloneFail(u *url.URL) func(*testing.T) {
return func(t *testing.T) {
- assert.Error(t, git.Clone(u.String(), dstLocalPath, git.CloneRepoOptions{}))
- assert.False(t, com.IsExist(filepath.Join(dstLocalPath, "README.md")))
+ tmpDir, err := ioutil.TempDir("", "doGitCloneFail")
+ assert.NoError(t, err)
+ defer os.RemoveAll(tmpDir)
+ assert.Error(t, git.Clone(u.String(), tmpDir, git.CloneRepoOptions{}))
+ assert.False(t, com.IsExist(filepath.Join(tmpDir, "README.md")))
}
}