-
Notifications
You must be signed in to change notification settings - Fork 12
/
github_user_aggregator_test.go
55 lines (41 loc) · 1.44 KB
/
github_user_aggregator_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
package keynuker
import (
"context"
"log"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tleyden/keynuker/keynuker-go-common"
)
// Not much of a unit test, just allows running ghUserAggregator.ListMembers() by hand in isolation
func TestGithubUserAggregator(t *testing.T) {
SkipIfIntegrationsTestsNotEnabled(t)
accessToken, ok := os.LookupEnv(keynuker_go_common.EnvVarKeyNukerTestGithubAccessToken)
if !ok {
t.Skipf("You must define environment variable keynuker_test_gh_access_token to run this test")
}
ghOrgs := []string{
"couchbase",
"couchbaselabs",
"couchbasedeps",
"couchbase-partners",
}
largestOrg := 0
numUsersInEachOrgIndividually := 0
for _, ghOrg := range ghOrgs {
ghUserAggregator := NewGithubUserAggregator([]string{ghOrg}, accessToken)
users, err := ghUserAggregator.ListMembers(context.Background())
assert.True(t, err == nil)
numUsersInEachOrgIndividually += len(users)
if len(users) > largestOrg {
largestOrg = len(users)
}
}
ghUserAggregator := NewGithubUserAggregator(ghOrgs, accessToken)
users, err := ghUserAggregator.ListMembers(context.Background())
assert.True(t, err == nil)
log.Printf("Members of all orgs %v: %v", ghOrgs, users)
log.Printf("# of Members: %v. numUsersInEachOrgIndividually: %v", len(users), numUsersInEachOrgIndividually)
assert.True(t, numUsersInEachOrgIndividually >= len(users)) // Can be lots of overlap
assert.True(t, len(users) > largestOrg)
}