Skip to content

Commit

Permalink
Fix GetByDetail tests to assert a new pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Sep 11, 2023
1 parent bddd6b3 commit 81dc45f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions engine/order_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1695,12 +1695,25 @@ func TestGetByDetail(t *testing.T) {
OrderID: "AdmiralHarold",
ClientOrderID: "DuskyLeafMonkey",
}
concise := &order.Detail{
id := &order.Detail{
Exchange: od.Exchange,
OrderID: od.OrderID,
}

assert.Nil(t, m.orderStore.getByDetail(od), "Fetching a non-stored order should return nil")
assert.Nil(t, m.orderStore.add(od), "Adding the details should not error")
assert.Same(t, m.orderStore.getByDetail(od), od, "Retrieve by full details should return the same pointer")
assert.Same(t, m.orderStore.getByDetail(concise), od, "Retrieve by other details should return the original pointer")

byOrig := m.orderStore.getByDetail(od)
byID := m.orderStore.getByDetail(id)

if assert.NotNil(t, byOrig, od, "Retrieve by orig pointer should find a record") {
assert.NotSame(t, byOrig, od, "Retrieve by orig pointer should return a new pointer")
assert.Equal(t, od.ClientOrderID, byOrig.ClientOrderID, "Retrieve by orig pointer should contain the correct ClientOrderID")
}

if assert.NotNil(t, byID, od, "Retrieve by new pointer should find a record") {
assert.NotSame(t, byID, id, "Retrieve by new pointer should return a different new pointer than we passed in")
assert.NotSame(t, byID, od, "Retrieve by new pointer should return a different new pointer than the original object")
assert.Equal(t, od.ClientOrderID, byID.ClientOrderID, "Retrieve by id pointer should contain the correct ClientOrderID")
}
}

0 comments on commit 81dc45f

Please sign in to comment.