Skip to content

Commit

Permalink
fix tests to use assert.ErrorIs() - group 2
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenolivia committed Mar 18, 2024
1 parent f93b129 commit e4ddbe4
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 129 deletions.
18 changes: 9 additions & 9 deletions organization_membership_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestOrganizationMembershipsList(t *testing.T) {
ml, err = client.OrganizationMemberships.List(ctx, orgTest.Name, &OrganizationMembershipListOptions{
Emails: []string{"foobar"},
})
assert.Equal(t, err, ErrInvalidEmail)
assert.ErrorIs(t, err, ErrInvalidEmail)
})
})

Expand Down Expand Up @@ -175,7 +175,7 @@ func TestOrganizationMembershipsCreate(t *testing.T) {
mem, err := client.OrganizationMemberships.Create(ctx, orgTest.Name, OrganizationMembershipCreateOptions{})

assert.Nil(t, mem)
assert.Equal(t, err, ErrRequiredEmail)
assert.ErrorIs(t, err, ErrRequiredEmail)
})

t.Run("with an invalid organization", func(t *testing.T) {
Expand All @@ -184,7 +184,7 @@ func TestOrganizationMembershipsCreate(t *testing.T) {
})

assert.Nil(t, mem)
assert.EqualError(t, err, ErrInvalidOrg.Error())
assert.ErrorIs(t, err, ErrInvalidOrg)
})

t.Run("when an error is returned from the api", func(t *testing.T) {
Expand Down Expand Up @@ -220,13 +220,13 @@ func TestOrganizationMembershipsRead(t *testing.T) {
t.Run("when the membership does not exist", func(t *testing.T) {
mem, err := client.OrganizationMemberships.Read(ctx, "nonexisting")
assert.Nil(t, mem)
assert.Equal(t, err, ErrResourceNotFound)
assert.ErrorIs(t, err, ErrResourceNotFound)
})

t.Run("with invalid membership id", func(t *testing.T) {
mem, err := client.OrganizationMemberships.Read(ctx, badIdentifier)
assert.Nil(t, mem)
assert.Equal(t, err, ErrInvalidMembership)
assert.ErrorIs(t, err, ErrInvalidMembership)
})
}

Expand Down Expand Up @@ -257,19 +257,19 @@ func TestOrganizationMembershipsReadWithOptions(t *testing.T) {
_, err := client.OrganizationMemberships.ReadWithOptions(ctx, memTest.ID, OrganizationMembershipReadOptions{
Include: []OrgMembershipIncludeOpt{"users"},
})
assert.Equal(t, err, ErrInvalidIncludeValue)
assert.ErrorIs(t, err, ErrInvalidIncludeValue)
})

t.Run("when the membership does not exist", func(t *testing.T) {
mem, err := client.OrganizationMemberships.ReadWithOptions(ctx, "nonexisting", options)
assert.Nil(t, mem)
assert.Equal(t, err, ErrResourceNotFound)
assert.ErrorIs(t, err, ErrResourceNotFound)
})

t.Run("with invalid membership id", func(t *testing.T) {
mem, err := client.OrganizationMemberships.ReadWithOptions(ctx, badIdentifier, options)
assert.Nil(t, mem)
assert.Equal(t, err, ErrInvalidMembership)
assert.ErrorIs(t, err, ErrInvalidMembership)
})
}

Expand All @@ -295,7 +295,7 @@ func TestOrganizationMembershipsDelete(t *testing.T) {
t.Run("when membership is invalid", func(t *testing.T) {
err := client.OrganizationMemberships.Delete(ctx, badIdentifier)

assert.Equal(t, err, ErrInvalidMembership)
assert.ErrorIs(t, err, ErrInvalidMembership)
})

t.Run("when an error is returned from the api", func(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions plan_export_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestPlanExportsCreate(t *testing.T) {

pe, err := client.PlanExports.Create(ctx, options)
assert.Nil(t, pe)
assert.Equal(t, err, ErrRequiredPlan)
assert.ErrorIs(t, err, ErrRequiredPlan)
})

t.Run("without a data type", func(t *testing.T) {
Expand All @@ -55,7 +55,7 @@ func TestPlanExportsCreate(t *testing.T) {

pe, err := client.PlanExports.Create(ctx, options)
assert.Nil(t, pe)
assert.Equal(t, err, ErrRequiredDataType)
assert.ErrorIs(t, err, ErrRequiredDataType)
})
}

Expand All @@ -78,7 +78,7 @@ func TestPlanExportsRead(t *testing.T) {
t.Run("without a valid ID", func(t *testing.T) {
pe, err := client.PlanExports.Read(ctx, badIdentifier)
assert.Nil(t, pe)
assert.Equal(t, err, ErrInvalidPlanExportID)
assert.ErrorIs(t, err, ErrInvalidPlanExportID)
})
}

Expand All @@ -96,12 +96,12 @@ func TestPlanExportsDelete(t *testing.T) {

t.Run("when the export does not exist", func(t *testing.T) {
err := client.Policies.Delete(ctx, "pe-doesntexist")
assert.Equal(t, err, ErrResourceNotFound)
assert.ErrorIs(t, err, ErrResourceNotFound)
})

t.Run("without a valid ID", func(t *testing.T) {
err := client.PlanExports.Delete(ctx, badIdentifier)
assert.Equal(t, err, ErrInvalidPlanExportID)
assert.ErrorIs(t, err, ErrInvalidPlanExportID)
})
}

Expand All @@ -121,7 +121,7 @@ func TestPlanExportsDownload(t *testing.T) {
t.Run("without a valid ID", func(t *testing.T) {
pe, err := client.PlanExports.Download(ctx, badIdentifier)
assert.Nil(t, pe)
assert.Equal(t, err, ErrInvalidPlanExportID)
assert.ErrorIs(t, err, ErrInvalidPlanExportID)
})
}

Expand Down
4 changes: 2 additions & 2 deletions plan_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ func TestPlansRead(t *testing.T) {
t.Run("when the plan does not exist", func(t *testing.T) {
p, err := client.Plans.Read(ctx, "nonexisting")
assert.Nil(t, p)
assert.Equal(t, err, ErrResourceNotFound)
assert.ErrorIs(t, err, ErrResourceNotFound)
})

t.Run("with invalid plan ID", func(t *testing.T) {
p, err := client.Plans.Read(ctx, badIdentifier)
assert.Nil(t, p)
assert.Equal(t, err, ErrInvalidPlanID)
assert.ErrorIs(t, err, ErrInvalidPlanID)
})
}

Expand Down
6 changes: 3 additions & 3 deletions policy_check_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ func TestPolicyChecksRead(t *testing.T) {
t.Run("when the policy check does not exist", func(t *testing.T) {
pc, err := client.PolicyChecks.Read(ctx, "nonexisting")
assert.Nil(t, pc)
assert.Equal(t, ErrResourceNotFound, err)
assert.ErrorIs(t, ErrResourceNotFound, err)
})

t.Run("without a valid policy check ID", func(t *testing.T) {
pc, err := client.PolicyChecks.Read(ctx, badIdentifier)
assert.Nil(t, pc)
assert.Equal(t, err, ErrInvalidPolicyCheckID)
assert.ErrorIs(t, err, ErrInvalidPolicyCheckID)
})
}

Expand Down Expand Up @@ -179,7 +179,7 @@ func TestPolicyChecksOverride(t *testing.T) {
t.Run("without a valid policy check ID", func(t *testing.T) {
p, err := client.PolicyChecks.Override(ctx, badIdentifier)
assert.Nil(t, p)
assert.Equal(t, err, ErrInvalidPolicyCheckID)
assert.ErrorIs(t, err, ErrInvalidPolicyCheckID)
})
}

Expand Down
6 changes: 3 additions & 3 deletions policy_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func TestPoliciesCreate(t *testing.T) {

p, err := client.Policies.Create(ctx, orgTest.Name, options)
assert.Nil(t, p)
assert.Equal(t, err, ErrRequiredEnforcementPath)
assert.ErrorIs(t, err, ErrRequiredEnforcementPath)
})

t.Run("when options is missing enforcement path", func(t *testing.T) {
Expand Down Expand Up @@ -419,7 +419,7 @@ func TestPoliciesRead(t *testing.T) {
t.Run("when the policy does not exist", func(t *testing.T) {
p, err := client.Policies.Read(ctx, "nonexisting")
assert.Nil(t, p)
assert.Equal(t, ErrResourceNotFound, err)
assert.ErrorIs(t, ErrResourceNotFound, err)
})

t.Run("without a valid policy ID", func(t *testing.T) {
Expand Down Expand Up @@ -604,7 +604,7 @@ func TestPoliciesUpload(t *testing.T) {

t.Run("without a valid policy ID", func(t *testing.T) {
err := client.Policies.Upload(ctx, badIdentifier, []byte(`main = rule { true }`))
assert.Equal(t, err, ErrInvalidPolicyID)
assert.ErrorIs(t, err, ErrInvalidPolicyID)
})
}

Expand Down
Loading

0 comments on commit e4ddbe4

Please sign in to comment.