From 76f97dd5b7af66408159ea936d00fbbb0ec5a42e Mon Sep 17 00:00:00 2001 From: Michael Christenson II Date: Thu, 21 Dec 2023 16:11:32 -0500 Subject: [PATCH] Pass by value in for loop, not by reference. (#953) * Pass by value in for loop, not by reference. * DXCDT-400: Allowing piped-in templates into `auth0 ul templates update` (#950) Adding piped-in HTML and updated docs * Bump github.com/hashicorp/terraform-exec from 0.19.0 to 0.20.0 (#951) Bumps [github.com/hashicorp/terraform-exec](https://github.com/hashicorp/terraform-exec) from 0.19.0 to 0.20.0. - [Release notes](https://github.com/hashicorp/terraform-exec/releases) - [Changelog](https://github.com/hashicorp/terraform-exec/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-exec/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-exec dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Organize imports --------- Signed-off-by: dependabot[bot] Co-authored-by: Will Vedder Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- internal/display/members.go | 4 ++-- internal/display/members_test.go | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 internal/display/members_test.go diff --git a/internal/display/members.go b/internal/display/members.go index b232ef401..dab543aa6 100644 --- a/internal/display/members.go +++ b/internal/display/members.go @@ -42,13 +42,13 @@ func (r *Renderer) MembersList(members []management.OrganizationMember) { var res []View for _, m := range members { - res = append(res, makeMembersView(&m)) + res = append(res, makeMembersView(m)) } r.Results(res) } -func makeMembersView(member *management.OrganizationMember) *membersView { +func makeMembersView(member management.OrganizationMember) *membersView { return &membersView{ ID: member.GetUserID(), Name: member.GetName(), diff --git a/internal/display/members_test.go b/internal/display/members_test.go new file mode 100644 index 000000000..dc2f63012 --- /dev/null +++ b/internal/display/members_test.go @@ -0,0 +1,36 @@ +package display + +import ( + "bytes" + "encoding/json" + "io" + "testing" + + "github.com/auth0/go-auth0/management" + "github.com/stretchr/testify/assert" +) + +func TestRenderer_MembersList_json(t *testing.T) { + var input []management.OrganizationMember + for _, id := range []string{"1234", "5678"} { + nid := id + input = append(input, management.OrganizationMember{UserID: &nid}) + } + + var exp []interface{} + raw, _ := json.Marshal(input) + _ = json.Unmarshal(raw, &exp) + + r := NewRenderer() + r.Format = OutputFormatJSON + + out := bytes.NewBuffer([]byte{}) + r.ResultWriter = out + r.MembersList(input) + buf, _ := io.ReadAll(out) + + var got []interface{} + _ = json.Unmarshal(buf, &got) + + assert.Equal(t, exp, got) +}