Skip to content

Commit 2c69fdb

Browse files
committed
Updating integration test for condition check
Previous version was occasionally failing when all tests run.
1 parent ee326fc commit 2c69fdb

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

test/integration/integrationTests.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ beforeAll(async () => {
7676
})
7777

7878
export async function scanWithDocClient(tableName: string) {
79-
return (await documentClient.send(new ScanCommand({ TableName: tableName }))).Items ?? []
79+
return (
80+
(await documentClient.send(new ScanCommand({ TableName: tableName, ConsistentRead: true }))).Items ?? []
81+
)
8082
}
8183

8284
export async function emptyTable(tableName: string, isCustomTable?: boolean) {
@@ -830,17 +832,11 @@ describe('standard single table', () => {
830832
async () =>
831833
await store.transactions
832834
.buildWriteTransaction(SHEEP_ENTITY)
833-
.put(shaunTheSheep)
834835
.conditionCheck(bobTheSheep, { conditionExpression: 'attribute_exists(PK)' })
835836
.execute()
836-
).rejects.toThrowError()
837-
838-
// Should succeed because bob doesn't exist
839-
await store.transactions
840-
.buildWriteTransaction(SHEEP_ENTITY)
841-
.put(shaunTheSheep)
842-
.conditionCheck(bobTheSheep, { conditionExpression: 'attribute_not_exists(PK)' })
843-
.execute()
837+
).rejects.toThrowError(
838+
'Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]'
839+
)
844840
})
845841

846842
test('get', async () => {

0 commit comments

Comments
 (0)