Skip to content

Commit

Permalink
Merge pull request #301 from OpsLevel/db/bugfix-identifier-input-need…
Browse files Browse the repository at this point in the history
…s-pointers

make UserIdentifierInput fields pointers
  • Loading branch information
davidbloss authored Nov 10, 2023
2 parents 081e76b + 9048c95 commit 79961b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Bugfix-20231110-135823.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Bugfix
body: make UserIdentifierInput fields pointers, fixing the omitempty struct tag behavior
time: 2023-11-10T13:58:23.41047-06:00
4 changes: 2 additions & 2 deletions team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ func TestTeamAddMemberhip(t *testing.T) {
team, _ := clientWithAlias.GetTeamWithAlias("example")
newMembership := ol.TeamMembershipUserInput{
Role: "user",
User: ol.UserIdentifierInput{Id: id1, Email: "[email protected]"},
User: ol.UserIdentifierInput{Id: &id1, Email: ol.NewString("[email protected]")},
}
result, err := clientWithTeamId.AddMemberships(&team.TeamId, newMembership)
// Assert
Expand Down Expand Up @@ -829,7 +829,7 @@ func TestTeamRemoveMemberhip(t *testing.T) {
team, _ := client1.GetTeamWithAlias("example")
membershipToDelete := ol.TeamMembershipUserInput{
Role: "user",
User: ol.UserIdentifierInput{Id: id1, Email: "[email protected]"},
User: ol.UserIdentifierInput{Id: &id1, Email: ol.NewString("[email protected]")},
}

result, err := client2.RemoveMemberships(&team.TeamId, membershipToDelete)
Expand Down
8 changes: 4 additions & 4 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type UserConnection struct {
}

type UserIdentifierInput struct {
Id ID `graphql:"id" json:"id,omitempty"`
Email string `graphql:"email" json:"email,omitempty"`
Id *ID `graphql:"id" json:"id,omitempty"`
Email *string `graphql:"email" json:"email,omitempty"`
}

type UserInput struct {
Expand All @@ -53,11 +53,11 @@ func (u *User) ResourceType() TaggableResource {
func NewUserIdentifier(value string) UserIdentifierInput {
if IsID(value) {
return UserIdentifierInput{
Id: ID(value),
Id: NewID(value),
}
}
return UserIdentifierInput{
Email: value,
Email: NewString(value),
}
}

Expand Down

0 comments on commit 79961b0

Please sign in to comment.