Skip to content

Commit

Permalink
chore(organization): add mutation organizationUpdateSharedAccount (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kporras07 authored May 23, 2024
1 parent 0e9a7fb commit 30f99e4
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .tutone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1455,8 +1455,8 @@ packages:
# max_query_field_depth: 2
# - name: organizationRevokeSharedAccount
# max_query_field_depth: 2
# - name: organizationUpdateSharedAccount
# max_query_field_depth: 2
- name: organizationUpdateSharedAccount
max_query_field_depth: 2
types:
- name: OrganizationNewManagedAccountInput
field_type_override: "*OrganizationNewManagedAccountInput"
Expand Down
48 changes: 48 additions & 0 deletions pkg/organization/organization_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/organization/organization_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"regexp"
"testing"

mock "github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers"
"github.com/stretchr/testify/require"

mock "github.com/newrelic/newrelic-client-go/v2/pkg/testhelpers"
)

func TestIntegrationOrganizationCreate_CustomerIdNotFoundError(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/organization/organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var (
unitTestMockOrganizationOneName = "Mock Organization One"
unitTestMockOrganizationOneId = "e1fe1ff8-0032-43d5-935f-caf47567a71d"

unitTestMockAccountOneId = 123456
unitTestMockLimitingRoleId = 1000

organizationNameUpdated = "Virtuoso / OaC Organization"
organizationId = os.Getenv("INTEGRATION_TESTING_NEW_RELIC_ORGANIZATION_ID")
)
Expand Down
44 changes: 44 additions & 0 deletions pkg/organization/organization_unit_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package organization

import (
"fmt"
"net/http"
"testing"

Expand All @@ -26,6 +27,21 @@ var (
}
}
}`

testUpdateSharedAccountResponseJSON = `{
"data": {
"organizationUpdateSharedAccount": {
"sharedAccount": {
"accountId": ` + fmt.Sprint(unitTestMockAccountOneId) + `,
"id": "` + unitTestMockOrganizationOneId + `",
"limitingRoleId": ` + fmt.Sprint(unitTestMockLimitingRoleId) + `,
"name": "` + unitTestMockOrganizationOneName + `",
"sourceOrganizationId": "` + unitTestMockOrganizationOneId + `",
"sourceOrganizationName": "` + unitTestMockOrganizationOneName + `"
}
}
}
}`
)

func TestUnitCreateOrganization(t *testing.T) {
Expand Down Expand Up @@ -76,3 +92,31 @@ func TestUnitUpdateOrganization(t *testing.T) {
assert.NotNil(t, actual)
assert.Equal(t, expected, actual)
}

func TestUnitOrganizationUpdateSharedAccount(t *testing.T) {
t.Parallel()

organization := newMockResponse(t, testUpdateSharedAccountResponseJSON, http.StatusOK)

expected := &OrganizationUpdateSharedAccountResponse{
SharedAccount: OrganizationSharedAccount{
AccountID: unitTestMockAccountOneId,
ID: unitTestMockOrganizationOneId,
LimitingRoleId: unitTestMockLimitingRoleId,
Name: unitTestMockOrganizationOneName,
SourceOrganizationId: unitTestMockOrganizationOneId,
SourceOrganizationName: unitTestMockOrganizationOneName,
},
}

actual, err := organization.OrganizationUpdateSharedAccount(
OrganizationUpdateSharedAccountInput{
ID: fmt.Sprint(unitTestMockAccountOneId),
LimitingRoleId: unitTestMockLimitingRoleId,
},
)

assert.NoError(t, err)
assert.NotNil(t, actual)
assert.Equal(t, expected, actual)
}

0 comments on commit 30f99e4

Please sign in to comment.