/
repo.go
51 lines (41 loc) · 1022 Bytes
/
repo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package helpers
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
var (
// A set of files to create in the initial commit.
repoFiles = map[string][]byte{
"README": []byte("README\n"),
"COPYING": []byte("COPYING\n"),
}
// A set of files to create in the branch commit.
branchFiles = map[string][]byte{
"AUTHORS": []byte("AUTHORS\n"),
}
)
const (
DefaultAuthor = "Author <author@example.com>"
)
// Get the files contained in the repository.
//
// This returns a copy of the original data structure, so it may be mutated by callers.
func GetRepoFiles() (files map[string][]byte) {
files = make(map[string][]byte)
for key, content := range repoFiles {
files[key] = content
}
for key, content := range branchFiles {
files[key] = content
}
return
}
// Clean up a testing repository.
//
// This deletes the temporary files from disk.
func CleanupRepository(t *testing.T, path string) {
t.Helper()
err := os.RemoveAll(path)
assert.Nil(t, err, "Could not cleanup repository")
}