-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathutil_test.go
94 lines (85 loc) · 2.06 KB
/
util_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
91
92
93
94
// Copyright 2017 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"testing"
"github.com/drone/go-scm/scm"
)
func Test_encodeListOptions(t *testing.T) {
opts := scm.ListOptions{
Page: 10,
Size: 30,
}
want := "page=10&per_page=30"
got := encodeListOptions(opts)
if got != want {
t.Errorf("Want encoded list options %q, got %q", want, got)
}
}
func Test_encodeCommitListOptions(t *testing.T) {
opts := scm.CommitListOptions{
Page: 10,
Size: 30,
Ref: "master",
}
want := "page=10&per_page=30&sha=master"
got := encodeCommitListOptions(opts)
if got != want {
t.Errorf("Want encoded commit list options %q, got %q", want, got)
}
}
func Test_encodeIssueListOptions(t *testing.T) {
opts := scm.IssueListOptions{
Page: 10,
Size: 30,
Open: true,
Closed: true,
}
want := "page=10&per_page=30&state=all"
got := encodeIssueListOptions(opts)
if got != want {
t.Errorf("Want encoded issue list options %q, got %q", want, got)
}
}
func Test_encodeIssueListOptions_Closed(t *testing.T) {
opts := scm.IssueListOptions{
Page: 10,
Size: 30,
Open: false,
Closed: true,
}
want := "page=10&per_page=30&state=closed"
got := encodeIssueListOptions(opts)
if got != want {
t.Errorf("Want encoded issue list options %q, got %q", want, got)
}
}
func Test_encodePullRequestListOptions(t *testing.T) {
t.Parallel()
opts := scm.PullRequestListOptions{
Page: 10,
Size: 30,
Open: true,
Closed: true,
}
want := "page=10&per_page=30&state=all"
got := encodePullRequestListOptions(opts)
if got != want {
t.Errorf("Want encoded pr list options %q, got %q", want, got)
}
}
func Test_encodePullRequestListOptions_Closed(t *testing.T) {
t.Parallel()
opts := scm.PullRequestListOptions{
Page: 10,
Size: 30,
Open: false,
Closed: true,
}
want := "page=10&per_page=30&state=closed"
got := encodePullRequestListOptions(opts)
if got != want {
t.Errorf("Want encoded pr list options %q, got %q", want, got)
}
}