mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-07 22:20:24 +00:00
Upgrade AWS SDK to the latest version
This commit is contained in:
+4
-1
@@ -6,6 +6,7 @@ methods connecting to DynamoDB, or as `unitTest` demonstrates, create your own
|
||||
## Test-compatible DynamoDB field
|
||||
If you use `*dynamodb.DynamoDB` as a field, you will be unable to unit test it,
|
||||
as documented in #88. Cast it instead as `dynamodbiface.DynamoDBAPI`:
|
||||
|
||||
```go
|
||||
type ItemGetter struct {
|
||||
DynamoDB dynamodbiface.DynamoDBAPI
|
||||
@@ -14,6 +15,7 @@ type ItemGetter struct {
|
||||
|
||||
## Querying actual DynamoDB
|
||||
You'll need an `*aws.Config` and `*session.Session` for these to work correctly:
|
||||
|
||||
```go
|
||||
// Setup
|
||||
var getter = new(ItemGetter)
|
||||
@@ -30,6 +32,7 @@ Construct a `fakeDynamoDB` and add the necessary methods for each of those
|
||||
structs (custom ones for `ItemGetter` and [whatever methods you're using for
|
||||
DynamoDB](https://github.com/aws/aws-sdk-go/blob/master/service/dynamodb/dynamodbiface/interface.go)),
|
||||
and you're good to go!
|
||||
|
||||
```go
|
||||
type fakeDynamoDB struct {
|
||||
dynamodbiface.DynamoDBAPI
|
||||
@@ -42,7 +45,7 @@ getter.DynamoDB.GetItem(/* ... */)
|
||||
|
||||
## Output
|
||||
```
|
||||
$ go test -cover
|
||||
$ go test -tags example -cover
|
||||
PASS
|
||||
coverage: 100.0% of statements
|
||||
ok _/Users/shatil/workspace/aws-sdk-go/example/service/dynamodb/unitTest 0.008s
|
||||
|
||||
Reference in New Issue
Block a user