-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegration_test.go
45 lines (35 loc) · 1.02 KB
/
integration_test.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
package main
import (
"bufio"
"bytes"
"io/ioutil"
"os"
"os/exec"
"testing"
"github.com/stretchr/testify/assert"
)
const GitDir = "git_directory"
func TestRemoteRepo(t *testing.T) {
os.Setenv("TZ", "UTC")
t.Run("slack-bot-1", func(t *testing.T) {
before := ""
after := "2019-09-04T17:14:43+02:00"
limit := 20
test(t, "../tests/test1.csv", "ls * | wc -l", "https://github.com/innogames/slack-bot.git", limit, before, after)
})
}
func test(t *testing.T, expectedFile string, command string, gitUrl string, limit int, after string, before string) {
os.RemoveAll(GitDir)
cmd := exec.Command("git", "clone", gitUrl, GitDir)
out, err := cmd.CombinedOutput()
assert.NoError(t, err, string(out))
defer os.RemoveAll(GitDir)
var actual bytes.Buffer
err = DumpHistory(GitDir, command, bufio.NewWriter(&actual), limit, after, before)
assert.NoError(t, err)
if expectedFile != "" {
expected, err := ioutil.ReadFile(expectedFile)
assert.NoError(t, err, expected)
assert.Equal(t, string(expected), actual.String())
}
}