-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
github_test.go
59 lines (48 loc) · 1.07 KB
/
github_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package github
import (
"bytes"
"fmt"
"os"
"testing"
st "github.com/golang-migrate/migrate/v4/source/testing"
"github.com/stretchr/testify/assert"
)
var GithubTestSecret = "" // username:token
func init() {
secrets, err := os.ReadFile(".github_test_secrets")
if err == nil {
GithubTestSecret = string(bytes.TrimSpace(secrets)[:])
}
}
func Test(t *testing.T) {
if len(GithubTestSecret) == 0 {
t.Skip("test requires .github_test_secrets")
}
g := &Github{}
d, err := g.Open("github://" + GithubTestSecret + "@mattes/migrate_test_tmp/test#452b8003e7")
if err != nil {
t.Fatal(err)
}
st.Test(t, d)
}
func TestDefaultClient(t *testing.T) {
g := &Github{}
owner := "golang-migrate"
repo := "migrate"
path := "source/github/examples/migrations"
url := fmt.Sprintf("github://%s/%s/%s", owner, repo, path)
d, err := g.Open(url)
if err != nil {
t.Fatal(err)
}
ver, err := d.First()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, uint(1085649617), ver)
ver, err = d.Next(ver)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, uint(1185749658), ver)
}