-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathproject_cards_test.go
90 lines (82 loc) · 2.16 KB
/
project_cards_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package repo
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/itchyny/github-migrator/github"
)
func TestRepoListProjectCards(t *testing.T) {
expected := []*github.ProjectCard{
{
ID: 1,
Note: "Test project card 1",
},
{
ID: 2,
Note: "Test project card 2",
},
}
repo := New(github.NewMockClient(
github.MockListProjectCards(func(int) github.ProjectCards {
return github.ProjectCardsFromSlice(expected)
}),
), "example/test")
got, err := github.ProjectCardsToSlice(repo.ListProjectCards(1))
assert.Nil(t, err)
assert.Equal(t, got, expected)
}
func TestRepoGetProjectCard(t *testing.T) {
expected := &github.ProjectCard{
ID: 1,
Note: "Test project card 1",
}
repo := New(github.NewMockClient(
github.MockGetProjectCard(func(int) (*github.ProjectCard, error) {
return expected, nil
}),
), "example/test")
got, err := repo.GetProjectCard(1)
assert.Nil(t, err)
assert.Equal(t, got, expected)
}
func TestRepoCreateProjectCard(t *testing.T) {
expected := &github.ProjectCard{
ID: 1,
Note: "Test project card 1",
}
repo := New(github.NewMockClient(
github.MockCreateProjectCard(func(int, *github.CreateProjectCardParams) (*github.ProjectCard, error) {
return expected, nil
}),
), "example/test")
got, err := repo.CreateProjectCard(10, nil)
assert.Nil(t, err)
assert.Equal(t, got, expected)
}
func TestRepoUpdateProjectCard(t *testing.T) {
expected := &github.ProjectCard{
ID: 1,
Note: "Test project card 1",
}
repo := New(github.NewMockClient(
github.MockUpdateProjectCard(func(int, *github.UpdateProjectCardParams) (*github.ProjectCard, error) {
return expected, nil
}),
), "example/test")
got, err := repo.UpdateProjectCard(1, nil)
assert.Nil(t, err)
assert.Equal(t, got, expected)
}
func TestRepoMoveProjectCard(t *testing.T) {
expected := &github.ProjectCard{
ID: 1,
Note: "Test project card 1",
}
repo := New(github.NewMockClient(
github.MockMoveProjectCard(func(int, *github.MoveProjectCardParams) (*github.ProjectCard, error) {
return expected, nil
}),
), "example/test")
got, err := repo.MoveProjectCard(1, nil)
assert.Nil(t, err)
assert.Equal(t, got, expected)
}