Skip to content

Commit

Permalink
remove some include field and add test for policy check
Browse files Browse the repository at this point in the history
  • Loading branch information
uturunku1 committed Mar 1, 2022
1 parent cdfae02 commit 8aad609
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
6 changes: 0 additions & 6 deletions organization_tags.go
Expand Up @@ -48,17 +48,11 @@ type OrganizationTag struct {
Organization *Organization `jsonapi:"relation,organization"`
}

type OrgTagsIncludeOp string

const OrgTagsEntitlementSet OrgTagsIncludeOp = "entitlement_set"

// OrganizationTagsListOptions represents the options for listing organization tags
type OrganizationTagsListOptions struct {
ListOptions
// Optional:
Filter string `url:"filter[exclude][taggable][id],omitempty"`

Include []OrgTagsIncludeOp `url:"include,omitempty"`
}

// OrganizationTagsDeleteOptions represents the request body for deleting a tag in an organization
Expand Down
6 changes: 0 additions & 6 deletions policy.go
Expand Up @@ -84,18 +84,12 @@ type EnforcementOptions struct {
Mode *EnforcementLevel `json:"mode"`
}

type PolicyIncludeOp string

const PolicyPolicySets PolicyIncludeOp = "policy_sets"

// PolicyListOptions represents the options for listing policies.
type PolicyListOptions struct {
ListOptions

// Optional: A search string (partial policy name) used to filter the results.
Search string `url:"search[name],omitempty"`

Include []PolicyIncludeOp `url:"include,omitempty"`
}

// PolicyCreateOptions represents the options for creating a new policy.
Expand Down
3 changes: 2 additions & 1 deletion policy_check.go
Expand Up @@ -110,6 +110,7 @@ type PolicyStatusTimestamps struct {
SoftFailedAt time.Time `jsonapi:"attr,soft-failed-at,rfc3339"`
}

// A list of relations to include
type PolicyCheckIncludeOp string

const (
Expand All @@ -121,7 +122,7 @@ const (
type PolicyCheckListOptions struct {
ListOptions

Include []PolicyCheckIncludeOp `url:"include,omitempty"`
Include []PolicyCheckIncludeOp `url:"include,omitempty"` // optional
}

// List all policy checks of the given run.
Expand Down
8 changes: 8 additions & 0 deletions policy_check_integration_test.go
Expand Up @@ -63,6 +63,14 @@ func TestPolicyChecksList(t *testing.T) {
assert.Equal(t, 1, pcl.TotalCount)
})

t.Run("with Include option", func(t *testing.T) {
pcl, err := client.PolicyChecks.List(ctx, rTest.ID, &PolicyCheckListOptions{
Include: []PolicyCheckIncludeOp{PolicyCheckRun},
})
require.NoError(t, err)
assert.NotEmpty(t, pcl.Items[0].Run.Status)
})

t.Run("without a valid run ID", func(t *testing.T) {
pcl, err := client.PolicyChecks.List(ctx, badIdentifier, nil)
assert.Nil(t, pcl)
Expand Down

0 comments on commit 8aad609

Please sign in to comment.