Skip to content

Commit

Permalink
TEMP MERGE WITH DUP COMMIT WHEN PASSES
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Oct 20, 2024
1 parent c92074d commit 6bc9c01
Showing 1 changed file with 16 additions and 65 deletions.
81 changes: 16 additions & 65 deletions tests/integration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,8 @@ func getIndexes(

var expectedErrorRaised bool

if action.NodeID.HasValue() {
nodeID := action.NodeID.Value()
nodeIDs, _ := getNodesWithIDs(action.NodeID, s.nodes)
for _, nodeID := range nodeIDs {
collections := s.collections[nodeID]
err := withRetryOnNode(
s.nodes[nodeID],
Expand All @@ -991,25 +991,6 @@ func getIndexes(
)
expectedErrorRaised = expectedErrorRaised ||
AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
} else {
for nodeID, collections := range s.collections {
err := withRetryOnNode(
s.nodes[nodeID],
func() error {
actualIndexes, err := collections[action.CollectionID].GetIndexes(s.ctx)
if err != nil {
return err
}

assertIndexesListsEqual(action.ExpectedIndexes,
actualIndexes, s.t, s.testCase.Description)

return nil
},
)
expectedErrorRaised = expectedErrorRaised ||
AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
}
}

assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)
Expand Down Expand Up @@ -1275,42 +1256,25 @@ func createDoc(
var expectedErrorRaised bool
var docIDs []client.DocID

if action.NodeID.HasValue() {
actionNode := s.nodes[action.NodeID.Value()]
collections := s.collections[action.NodeID.Value()]
nodeIDs, nodes := getNodesWithIDs(action.NodeID, s.nodes)
for index, node := range nodes {
nodeID := nodeIDs[index]
collection := s.collections[nodeID][action.CollectionID]
err := withRetryOnNode(
actionNode,
node,
func() error {
var err error
docIDs, err = mutation(
s,
action,
actionNode,
action.NodeID.Value(),
collections[action.CollectionID],
node,
nodeID,
collection,
)
return err
},
)
expectedErrorRaised = AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
} else {
for nodeID, collections := range s.collections {
err := withRetryOnNode(
s.nodes[nodeID],
func() error {
var err error
docIDs, err = mutation(
s,
action,
s.nodes[nodeID],
nodeID,
collections[action.CollectionID],
)
return err
},
)
expectedErrorRaised = AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
}
}

assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)
Expand Down Expand Up @@ -1483,33 +1447,20 @@ func deleteDoc(

var expectedErrorRaised bool

if action.NodeID.HasValue() {
nodeID := action.NodeID.Value()
actionNode := s.nodes[nodeID]
collections := s.collections[nodeID]
nodeIDs, nodes := getNodesWithIDs(action.NodeID, s.nodes)
for index, node := range nodes {
nodeID := nodeIDs[index]
collection := s.collections[nodeID][action.CollectionID]
identity := getIdentity(s, nodeID, action.Identity)
ctx := db.SetContextIdentity(s.ctx, identity)
err := withRetryOnNode(
actionNode,
node,
func() error {
_, err := collections[action.CollectionID].Delete(ctx, docID)
_, err := collection.Delete(ctx, docID)
return err
},
)
expectedErrorRaised = AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
} else {
for nodeID, collections := range s.collections {
identity := getIdentity(s, nodeID, action.Identity)
ctx := db.SetContextIdentity(s.ctx, identity)
err := withRetryOnNode(
s.nodes[nodeID],
func() error {
_, err := collections[action.CollectionID].Delete(ctx, docID)
return err
},
)
expectedErrorRaised = AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
}
}

assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised)
Expand Down

0 comments on commit 6bc9c01

Please sign in to comment.