-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
61 lines (53 loc) · 1.53 KB
/
main_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
package main
import (
"strings"
"testing"
"github.com/cuotos/outstanding-prs/filter"
"github.com/google/go-github/v33/github"
"github.com/stretchr/testify/assert"
)
func TestGenerateQueryString(t *testing.T) {
tcs := []struct {
Org string
Users []string
Expected []string
incApproved bool
}{
{
"TestOrg",
[]string{},
[]string{"org:TestOrg", "is:open", "review:required", "draft:false", "type:pr", "archived:false"},
false,
},
{
"SecondOrg",
[]string{"cuotos"},
[]string{"org:SecondOrg", "is:open", "review:required", "draft:false", "author:cuotos", "type:pr", "archived:false"},
false,
},
{
"AnotherOrg",
[]string{"cuotos", "danyo"},
[]string{"org:AnotherOrg", "is:open", "review:required", "draft:false", "type:pr", "author:cuotos", "author:danyo", "archived:false"},
false,
},
{
"TestOrg",
[]string{},
[]string{"org:TestOrg", "is:open", "draft:false", "type:pr", "archived:false"},
true,
},
}
for _, tc := range tcs {
var members []*github.User
for _, m := range tc.Users {
// ptr foo, else all the items in "members" will have the same Login string
// if you use &m in the append line
userName := m
members = append(members, &github.User{Login: &userName})
}
actual, _ := generateQueryString(tc.Org, members, filter.WithReviewRequired(!tc.incApproved)) //"inc approved" is "NOT requiring review", therefore have to negate the "approved" flag
actualFields := strings.Fields(actual)
assert.ElementsMatch(t, tc.Expected, actualFields)
}
}