Skip to content

Commit

Permalink
Add tests for including github repos. (trufflesecurity#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrav committed Oct 21, 2022
1 parent fb56b9f commit 46bc010
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/sources/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,29 @@ func TestEnumerateWithToken(t *testing.T) {
assert.True(t, gock.IsDone())
}

func TestEnumerateWithToken_IncludeRepos(t *testing.T) {
defer gock.Off()

gock.New("https://api.github.com").
Get("/user").
Reply(200).
JSON(map[string]string{"login": "super-secret-user"})

gock.New("https://api.github.com").
Get("/users/super-secret-user/gists").
Reply(200).
JSON([]map[string]string{{"clone_url": ""}})

s := initTestSource(nil)
s.repos = []string{"some-special-repo"}

err := s.enumerateWithToken(context.TODO(), "https://api.github.com", "token")
assert.Nil(t, err)
assert.Equal(t, 2, len(s.repos))
assert.Equal(t, []string{"some-special-repo", ""}, s.repos)
assert.True(t, gock.IsDone())
}

func TestEnumerateWithApp(t *testing.T) {
defer gock.Off()

Expand Down

0 comments on commit 46bc010

Please sign in to comment.