Skip to content

Commit

Permalink
Updating integration test for condition check
Browse files Browse the repository at this point in the history
Previous version was occasionally failing when
all tests run.
  • Loading branch information
mikebroberts committed Sep 25, 2023
1 parent ee326fc commit 2c69fdb
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions test/integration/integrationTests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ beforeAll(async () => {
})

export async function scanWithDocClient(tableName: string) {
return (await documentClient.send(new ScanCommand({ TableName: tableName }))).Items ?? []
return (
(await documentClient.send(new ScanCommand({ TableName: tableName, ConsistentRead: true }))).Items ?? []
)
}

export async function emptyTable(tableName: string, isCustomTable?: boolean) {
Expand Down Expand Up @@ -830,17 +832,11 @@ describe('standard single table', () => {
async () =>
await store.transactions
.buildWriteTransaction(SHEEP_ENTITY)
.put(shaunTheSheep)
.conditionCheck(bobTheSheep, { conditionExpression: 'attribute_exists(PK)' })
.execute()
).rejects.toThrowError()

// Should succeed because bob doesn't exist
await store.transactions
.buildWriteTransaction(SHEEP_ENTITY)
.put(shaunTheSheep)
.conditionCheck(bobTheSheep, { conditionExpression: 'attribute_not_exists(PK)' })
.execute()
).rejects.toThrowError(
'Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed]'
)
})

test('get', async () => {
Expand Down

0 comments on commit 2c69fdb

Please sign in to comment.