Skip to content

Commit

Permalink
chore: remove document client from unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumeduboc committed Jan 26, 2024
1 parent 23156cc commit 64864d8
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 130 deletions.
13 changes: 2 additions & 11 deletions src/v1/operations/batch/batchWrite.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'

import { DynamoDBToolboxError, EntityV2, TableV2, schema, string } from 'v1'
import { BatchPutItemRequest } from './putItem/operation'
import { BatchDeleteItemRequest } from './deleteItem/operation'
import { getBatchWriteCommandInput } from './batchWrite'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -19,8 +12,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})
const TestTable2 = new TableV2({
name: 'test-table2',
Expand All @@ -38,8 +30,7 @@ const TestTable2 = new TableV2({
sortKey: { name: 'GSIsk1', type: 'string' },
type: 'global'
}
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'

import { DynamoDBToolboxError, EntityV2, TableV2, schema, string } from 'v1'
import { BatchDeleteItemRequest } from './operation'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -17,8 +10,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down
10 changes: 1 addition & 9 deletions src/v1/operations/batch/putItem/BatchPutItemParams.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'

import { DynamoDBToolboxError, EntityV2, TableV2, schema, string } from 'v1'
import { BatchPutItemRequest } from './operation'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -17,8 +10,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'

import {
TableV2,
EntityV2,
Expand All @@ -11,10 +8,6 @@ import {
prefix
} from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -24,8 +17,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down
13 changes: 2 additions & 11 deletions src/v1/operations/getItem/getItemParams/getItemParams.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'

import { TableV2, EntityV2, schema, string, DynamoDBToolboxError, GetItemCommand, prefix } from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -16,8 +9,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand All @@ -33,8 +25,7 @@ const TestEntity = new EntityV2({
const TestTable2 = new TableV2({
name: 'test-table',
partitionKey: { type: 'string', name: 'pk' },
sortKey: { type: 'string', name: 'sk' },
documentClient
sortKey: { type: 'string', name: 'sk' }
})

const TestEntity2 = new EntityV2({
Expand Down
16 changes: 3 additions & 13 deletions src/v1/operations/putItem/putItemParams/putItemParams.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'

import {
TableV2,
EntityV2,
Expand All @@ -19,10 +16,6 @@ import {
prefix
} from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -32,8 +25,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down Expand Up @@ -62,8 +54,7 @@ const TestEntity = new EntityV2({

const TestTable2 = new TableV2({
name: 'test-table',
partitionKey: { type: 'string', name: 'pk' },
documentClient
partitionKey: { type: 'string', name: 'pk' }
})

const TestEntity2 = new EntityV2({
Expand Down Expand Up @@ -97,8 +88,7 @@ const TestEntity3 = new EntityV2({
const TestTable3 = new TableV2({
name: 'TestTable3',
partitionKey: { type: 'string', name: 'pk' },
sortKey: { type: 'string', name: 'sk' },
documentClient
sortKey: { type: 'string', name: 'sk' }
})

const TestEntity4 = new EntityV2({
Expand Down
9 changes: 1 addition & 8 deletions src/v1/operations/query/queryParams/queryParams.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import type { A } from 'ts-toolbelt'

import {
Expand All @@ -15,10 +13,6 @@ import {
prefix
} from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand Down Expand Up @@ -48,8 +42,7 @@ const TestTable = new TableV2({
type: 'string'
}
}
},
documentClient
}
})

const Entity1 = new EntityV2({
Expand Down
9 changes: 1 addition & 8 deletions src/v1/operations/scan/scanParams/scanParams.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import type { A } from 'ts-toolbelt'

import {
Expand All @@ -15,10 +13,6 @@ import {
prefix
} from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -41,8 +35,7 @@ const TestTable = new TableV2({
type: 'string'
}
}
},
documentClient
}
})

const Entity1 = new EntityV2({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'

import { TableV2, EntityV2, schema, string, DynamoDBToolboxError } from 'v1'
import { DeleteItemTransaction } from '../operation'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -17,8 +10,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'

import {
TableV2,
EntityV2,
Expand All @@ -17,10 +14,6 @@ import {
PutItemTransaction
} from 'v1'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -30,8 +23,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand All @@ -58,8 +50,7 @@ const TestEntity = new EntityV2({

const TestTable2 = new TableV2({
name: 'test-table',
partitionKey: { type: 'string', name: 'pk' },
documentClient
partitionKey: { type: 'string', name: 'pk' }
})

const TestEntity2 = new EntityV2({
Expand Down Expand Up @@ -93,8 +84,7 @@ const TestEntity3 = new EntityV2({
const TestTable3 = new TableV2({
name: 'TestTable3',
partitionKey: { type: 'string', name: 'pk' },
sortKey: { type: 'string', name: 'sk' },
documentClient
sortKey: { type: 'string', name: 'sk' }
})

const TestEntity4 = new EntityV2({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb'
import { DynamoDBClient } from '@aws-sdk/client-dynamodb'

import {
TableV2,
EntityV2,
Expand Down Expand Up @@ -30,10 +27,6 @@ import {
$prepend
} from 'v1/operations/updateItem/utils'

const dynamoDbClient = new DynamoDBClient({})

const documentClient = DynamoDBDocumentClient.from(dynamoDbClient)

const TestTable = new TableV2({
name: 'test-table',
partitionKey: {
Expand All @@ -43,8 +36,7 @@ const TestTable = new TableV2({
sortKey: {
type: 'string',
name: 'sk'
},
documentClient
}
})

const TestEntity = new EntityV2({
Expand Down Expand Up @@ -88,8 +80,7 @@ const TestTable2 = new TableV2({
partitionKey: {
type: 'string',
name: 'pk'
},
documentClient
}
})

const TestEntity2 = new EntityV2({
Expand Down Expand Up @@ -121,8 +112,7 @@ const TestTable3 = new TableV2({
partitionKey: {
type: 'string',
name: 'pk'
},
documentClient
}
})

const TestEntity3 = new EntityV2({
Expand All @@ -142,8 +132,7 @@ const TestTable4 = new TableV2({
partitionKey: {
type: 'string',
name: 'pk'
},
documentClient
}
})

const TestEntity4 = new EntityV2({
Expand Down

0 comments on commit 64864d8

Please sign in to comment.