Skip to content

Commit

Permalink
testing: create attributeSet if not present for TestAttributeSetClient
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed May 17, 2024
1 parent 5ea161b commit 1c56ff6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
32 changes: 22 additions & 10 deletions msgraph/attribute_set_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package msgraph_test

import (
"net/http"
"testing"

"github.com/hashicorp/go-azure-sdk/sdk/odata"
Expand All @@ -9,25 +10,36 @@ import (
"github.com/manicminer/hamilton/msgraph"
)

const attributeSetId = "test"

func TestAttributeSetClient(t *testing.T) {
c := test.NewTest(t)
defer c.CancelFunc()

attributeSet := testAttributeSetClientCreate(
t,
c,
msgraph.AttributeSet{
Description: utils.StringPtr("test attribute set"),
ID: utils.StringPtr(c.RandomString),
},
)
c.AttributeSetClient.BaseClient.DisableRetries = true
_, status, err := c.AttributeSetClient.Get(c.Context, attributeSetId, odata.Query{})
c.AttributeSetClient.BaseClient.DisableRetries = false
if err != nil {
if status != http.StatusNotFound {
t.Fatalf("AttributeSetClient.Get(): unable to retrieve attribute set for testing: %v", err)
}

testAttributeSetClientCreate(
t,
c,
msgraph.AttributeSet{
Description: utils.StringPtr("test attribute set"),
ID: utils.StringPtr(attributeSetId),
},
)
}

testAttributeSetClientGet(t, c, *attributeSet.ID)
testAttributeSetClientGet(t, c, attributeSetId)
testAttributeSetClientUpdate(
t,
c,
msgraph.AttributeSet{
ID: attributeSet.ID,
ID: utils.StringPtr(attributeSetId),
Description: utils.StringPtr("updated test description"),
},
)
Expand Down
2 changes: 0 additions & 2 deletions msgraph/custom_security_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/manicminer/hamilton/msgraph"
)

const attributeSetId = "test"

func TestCustomSecurityAttributeDefinitionClient(t *testing.T) {
c := test.NewTest(t)
defer c.CancelFunc()
Expand Down

0 comments on commit 1c56ff6

Please sign in to comment.