Skip to content

Commit

Permalink
Fix bug collaborators all mapped to last
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofranssen committed Jul 29, 2020
1 parent 4aeb724 commit 52261c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/github/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ func mapTopics(topics graphql.RepositoryTopics) []Topic {

func mapCollaborators(collaborators graphql.Collaborators) []Collaborator {
ghCollaborators := make([]Collaborator, len(collaborators.Nodes))
for i, collaborator := range collaborators.Nodes {
ghCollaborators[i] = Collaborator{&collaborator}
for i := range collaborators.Nodes {
ghCollaborators[i] = Collaborator{&collaborators.Nodes[i]}
}
return ghCollaborators
}
Expand Down
6 changes: 6 additions & 0 deletions lib/github/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func TestMap(t *testing.T) {
collaborators := graphql.Collaborators{
Nodes: []graphql.Collaborator{
graphql.Collaborator{Name: "Marco Franssen", Login: "marcofranssen", AvatarURL: "https://avatars3.githubusercontent.com/u/694733?u=6aeb327c48cb88ae31eb88e680b96228f53cae51&v=4"},
graphql.Collaborator{Name: "John Doe", Login: "johndoe", AvatarURL: "https://avatars3.githubusercontent.com/u/694733?u=6aeb327c48cb88ae31eb88e680b96228f53cae51&v=4"},
},
}
graphqlRepositories := []graphql.Repository{
Expand Down Expand Up @@ -109,9 +110,14 @@ func TestMap(t *testing.T) {
assert.Equal("graphql", ghRepos[2].Topics[2].Name)
assert.Equal("https://github.com/topics/graphql", ghRepos[2].Topics[2].URL)

assert.Len(ghRepos[3].Collaborators, 2)
assert.Equal("Marco Franssen", ghRepos[3].Collaborators[0].Name)
assert.Equal("marcofranssen", ghRepos[3].Collaborators[0].Login)
assert.Equal("https://avatars3.githubusercontent.com/u/694733?u=6aeb327c48cb88ae31eb88e680b96228f53cae51&v=4", ghRepos[3].Collaborators[0].AvatarURL)

assert.Equal("John Doe", ghRepos[3].Collaborators[1].Name)
assert.Equal("johndoe", ghRepos[3].Collaborators[1].Login)
assert.Equal("https://avatars3.githubusercontent.com/u/694733?u=6aeb327c48cb88ae31eb88e680b96228f53cae51&v=4", ghRepos[3].Collaborators[1].AvatarURL)
}

func stringPointer(s string) *string {
Expand Down

0 comments on commit 52261c6

Please sign in to comment.