Skip to content

Commit

Permalink
feat: update response for create team endpoint (#34)
Browse files Browse the repository at this point in the history
Fixes #33
  • Loading branch information
mefellows authored Nov 27, 2023
1 parent bb5553c commit 80b7d49
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion broker/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type TeamEmbeddedItems struct {
}

type TeamsResponse struct {
Teams []Team `json:"teams"`
Team
HalDoc
}

Expand Down
10 changes: 1 addition & 9 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,7 @@ func (c *Client) CreateTeam(t broker.TeamCreateOrUpdateRequest) (*broker.Team, e

apiResponse := res.(*broker.TeamsResponse)

// TODO: why is this a collection not a single resource?
// check if it's consistent with the other APIs
for _, i := range apiResponse.Teams {
if i.Name == t.Name {
return &i, err
}
}

return nil, err
return &apiResponse.Team, err
}

// ReadTeamAssignments finds all users currently in a team
Expand Down
6 changes: 1 addition & 5 deletions client/client_pact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ func TestTerraformClientPact(t *testing.T) {
WithJSONBody(Like(create)).
WillRespondWith(200).
WithHeader("Content-Type", S("application/hal+json")).
WithJSONBody(Like(broker.TeamsResponse{
Teams: []broker.Team{
created,
},
}))
WithJSONBody(Like(created))

err = mockProvider.ExecuteTest(t, func(config MockServerConfig) error {
client := clientForPact(config)
Expand Down

0 comments on commit 80b7d49

Please sign in to comment.