Skip to content

Commit

Permalink
improve comments + add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinalirao committed Nov 3, 2022
1 parent 45e7d8f commit a09933d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion policy.go
Expand Up @@ -111,7 +111,7 @@ type PolicyCreateOptions struct {
Name *string `jsonapi:"attr,name"`

// **Note: This field is still in BETA and subject to change.**
// Optional: The underlying technology that the policy supports.
// Optional: The underlying technology that the policy supports. Defaults to Sentinel if not specified for PolicyCreate.
Kind PolicyKind `jsonapi:"attr,kind,omitempty"`

// **Note: This field is still in BETA and subject to change.**
Expand Down
16 changes: 15 additions & 1 deletion policy_integration_beta_test.go
Expand Up @@ -193,7 +193,7 @@ func TestPoliciesCreate_Beta(t *testing.T) {
assert.Equal(t, err, ErrRequiredEnforcementPath)
})

t.Run("when options is missing enforcement path", func(t *testing.T) {
t.Run("when options is missing enforcement mode", func(t *testing.T) {
name := randomString(t)
options := PolicyCreateOptions{
Name: String(name),
Expand Down Expand Up @@ -346,4 +346,18 @@ func TestPoliciesUpdate_Beta(t *testing.T) {
assert.NotEqual(t, *pBefore.Query, *pAfter.Query)
assert.Equal(t, "terraform.policy1.deny", *pAfter.Query)
})

t.Run("update query when kind is not OPA", func(t *testing.T) {
pBefore, pBeforeCleanup := createUploadedPolicy(t, client, true, orgTest)
defer pBeforeCleanup()

pAfter, err := client.Policies.Update(ctx, pBefore.ID, PolicyUpdateOptions{
Query: String("terraform.policy1.deny"),
})
require.NoError(t, err)

assert.Equal(t, pBefore.Name, pAfter.Name)
assert.Equal(t, pBefore.Enforce, pAfter.Enforce)
assert.Nil(t, pAfter.Query)
})
}

0 comments on commit a09933d

Please sign in to comment.