From a09933d67a9621dbacd4f9c9d9da23dae719a4c1 Mon Sep 17 00:00:00 2001 From: mrinalirao Date: Fri, 4 Nov 2022 09:24:38 +1100 Subject: [PATCH] improve comments + add additional test --- policy.go | 2 +- policy_integration_beta_test.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/policy.go b/policy.go index 330821185..0baa9530b 100644 --- a/policy.go +++ b/policy.go @@ -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.** diff --git a/policy_integration_beta_test.go b/policy_integration_beta_test.go index 3788c2c27..61e560875 100644 --- a/policy_integration_beta_test.go +++ b/policy_integration_beta_test.go @@ -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), @@ -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) + }) }