Skip to content

Commit

Permalink
PR(ADHERE-REVIEW): Check require.Equal after the `assertExpectedErr…
Browse files Browse the repository at this point in the history
…orRaised`
  • Loading branch information
shahzadlone committed Oct 4, 2024
1 parent b48a4e3 commit 9d7e222
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions tests/integration/acp.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ func addPolicyACP(
ctx := db.SetContextIdentity(s.ctx, identity)
policyResult, err := node.AddPolicy(ctx, action.Policy)

if err == nil {
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

if !expectedErrorRaised {
require.Equal(s.t, action.ExpectedError, "")
require.Equal(s.t, action.ExpectedPolicyID, policyResult.PolicyID)
}

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

// The policy should only be added to a SourceHub chain once - there is no need to loop through
// the nodes.
if acpType == SourceHubACPType {
Expand Down Expand Up @@ -236,13 +236,13 @@ func addDocActorRelationshipACP(
targetIdentity,
)

if err == nil {
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

if !expectedErrorRaised {
require.Equal(s.t, action.ExpectedError, "")
require.Equal(s.t, action.ExpectedExistence, exists.ExistedAlready)
}

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)
} else {
for i, node := range getNodes(action.NodeID, s.nodes) {
var collectionName string
Expand Down Expand Up @@ -293,14 +293,14 @@ func addDocActorRelationshipACP(
targetIdentity,
)

if err == nil {
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

if !expectedErrorRaised {
require.Equal(s.t, action.ExpectedError, "")
require.Equal(s.t, action.ExpectedExistence, exists.ExistedAlready)
}

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

// The relationship should only be added to a SourceHub chain once - there is no need to loop through
// the nodes.
if acpType == SourceHubACPType {
Expand Down Expand Up @@ -414,13 +414,13 @@ func deleteDocActorRelationshipACP(
targetIdentity,
)

if err == nil {
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

if !expectedErrorRaised {
require.Equal(s.t, action.ExpectedError, "")
require.Equal(s.t, action.ExpectedRecordFound, deleteDocActorRelationshipResult.RecordFound)
}

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)
} else {
for i, node := range getNodes(action.NodeID, s.nodes) {
var collectionName string
Expand Down Expand Up @@ -471,14 +471,14 @@ func deleteDocActorRelationshipACP(
targetIdentity,
)

if err == nil {
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

if !expectedErrorRaised {
require.Equal(s.t, action.ExpectedError, "")
require.Equal(s.t, action.ExpectedRecordFound, deleteDocActorRelationshipResult.RecordFound)
}

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)

// The relationship should only be added to a SourceHub chain once - there is no need to loop through
// the nodes.
if acpType == SourceHubACPType {
Expand Down

0 comments on commit 9d7e222

Please sign in to comment.