Skip to content

Commit

Permalink
Fix issue #36: Missing repository names when using the --org flag 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokosi committed Apr 27, 2022
1 parent 08f779b commit 2006e2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func scanRepo(config config, repoWithOrg string) (message string, repository rep
if config.verbose {
message += repoWithOrg + " has: "
}
if !config.verbose && (len(config.repo) > 1 || len(config.user) > 1) {
if !config.verbose && (len(config.repo) > 1 || len(config.user) > 1 || len(config.org) > 1) {
message += repoWithOrg + ": "
}
if len(readme.Name) > 0 {
Expand Down
19 changes: 19 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ func TestGetRepos_no_user_nor_org(t *testing.T) {
assert.Nil(t, error)
}

func TestScanRepo_Org(t *testing.T) {
defer gock.Off()
defer gock.DisableNetworking()
gock.New("https://api.github.com").
Get("/repos/acme/buzz/readme").
Reply(200).
JSON(map[string]string{"name": "buzz"})
gock.New("https://api.github.com").
Get("/repos/acme/buzz").
Reply(200).
File("test_repo.json")

message, repository, validRepo := scanRepo(config{org: "acme"}, "acme/buzz")

assert.True(t, validRepo)
assert.Equal(t, repo{Name: "buzz", Owner: owner{Login: "Coyote"}, Description: "Beep, beep", Topics: []string{"old", "cartoon"}, Visibility: "public"}, repository)
assert.Equal(t, "acme/buzz: README ☑️, topics ☑️, ", message)
}

func TestScanRepo_Verbose(t *testing.T) {
defer gock.Off()
defer gock.DisableNetworking()
Expand Down

0 comments on commit 2006e2d

Please sign in to comment.