diff options
author | Michael Muré <batolettre@gmail.com> | 2019-02-16 13:48:46 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-03-01 22:40:24 +0100 |
commit | cd7ed7ff9e3250c10e97fe16c934b5a6151527bb (patch) | |
tree | e0d6df60e2a04ccb72b3d4c63fc57b4546df458c /util | |
parent | 21048e785d976a04e26798e4a385ee675c95b88f (diff) | |
download | git-bug-cd7ed7ff9e3250c10e97fe16c934b5a6151527bb.tar.gz |
identity: add more test for serialisation and push/pull/merge + fixes
Diffstat (limited to 'util')
-rw-r--r-- | util/test/repo.go | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/util/test/repo.go b/util/test/repo.go index 8f0d2e5d..c5d3c000 100644 --- a/util/test/repo.go +++ b/util/test/repo.go @@ -3,8 +3,9 @@ package test import ( "io/ioutil" "log" + "os" + "testing" - "github.com/MichaelMure/git-bug/misc/random_bugs" "github.com/MichaelMure/git-bug/repository" ) @@ -39,14 +40,40 @@ func CreateRepo(bare bool) *repository.GitRepo { return repo } -func CreateFilledRepo(bugNumber int) repository.ClockedRepo { - repo := CreateRepo(false) +func CleanupRepo(repo repository.Repo) error { + path := repo.GetPath() + // fmt.Println("Cleaning repo:", path) + return os.RemoveAll(path) +} - var seed int64 = 42 - options := random_bugs.DefaultOptions() +func SetupReposAndRemote(t testing.TB) (repoA, repoB, remote *repository.GitRepo) { + repoA = CreateRepo(false) + repoB = CreateRepo(false) + remote = CreateRepo(true) - options.BugNumber = bugNumber + remoteAddr := "file://" + remote.GetPath() - random_bugs.CommitRandomBugsWithSeed(repo, options, seed) - return repo + err := repoA.AddRemote("origin", remoteAddr) + if err != nil { + t.Fatal(err) + } + + err = repoB.AddRemote("origin", remoteAddr) + if err != nil { + t.Fatal(err) + } + + return repoA, repoB, remote +} + +func CleanupRepos(repoA, repoB, remote *repository.GitRepo) { + if err := CleanupRepo(repoA); err != nil { + log.Println(err) + } + if err := CleanupRepo(repoB); err != nil { + log.Println(err) + } + if err := CleanupRepo(remote); err != nil { + log.Println(err) + } } |