sqs-browse: fixed pad printf and fixed test parallel
This commit is contained in:
parent
c9a31eae35
commit
fb749aaee2
|
@ -10,9 +10,10 @@ import (
|
|||
)
|
||||
|
||||
func TestProvider_ScanItems(t *testing.T) {
|
||||
tableName := "test-table"
|
||||
tableName := "provider-scanimages-test-table"
|
||||
|
||||
client := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
client, cleanupFn := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
defer cleanupFn()
|
||||
provider := dynamo.NewProvider(client)
|
||||
|
||||
t.Run("should return scanned items from the table", func(t *testing.T) {
|
||||
|
@ -37,10 +38,11 @@ func TestProvider_ScanItems(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvider_DeleteItem(t *testing.T) {
|
||||
tableName := "test-table"
|
||||
tableName := "provider-deleteitem-test-table"
|
||||
|
||||
t.Run("should delete item if exists in table", func(t *testing.T) {
|
||||
client := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
client, cleanupFn := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
defer cleanupFn()
|
||||
provider := dynamo.NewProvider(client)
|
||||
|
||||
ctx := context.Background()
|
||||
|
@ -61,7 +63,8 @@ func TestProvider_DeleteItem(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("should do nothing if key does not exist", func(t *testing.T) {
|
||||
client := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
client, cleanupFn := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
defer cleanupFn()
|
||||
provider := dynamo.NewProvider(client)
|
||||
|
||||
ctx := context.Background()
|
||||
|
@ -81,7 +84,8 @@ func TestProvider_DeleteItem(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("should return error if table name does not exist", func(t *testing.T) {
|
||||
client := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
client, cleanupFn := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
defer cleanupFn()
|
||||
provider := dynamo.NewProvider(client)
|
||||
|
||||
ctx := context.Background()
|
||||
|
|
|
@ -10,9 +10,10 @@ import (
|
|||
)
|
||||
|
||||
func TestService_Scan(t *testing.T) {
|
||||
tableName := "test-table"
|
||||
tableName := "service-scan-test-table"
|
||||
|
||||
client := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
client, cleanupFn := testdynamo.SetupTestTable(t, tableName, testData)
|
||||
defer cleanupFn()
|
||||
provider := dynamo.NewProvider(client)
|
||||
|
||||
t.Run("return all columns and fields in sorted order", func(t *testing.T) {
|
||||
|
|
|
@ -34,7 +34,7 @@ func (s *Service) Poll(ctx context.Context) error {
|
|||
|
||||
for _, msg := range newMsgs {
|
||||
if err := s.store.Save(ctx, msg); err != nil {
|
||||
log.Println("warn: unable to save new message %v", err)
|
||||
log.Printf("warn: unable to save new message %v", err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
type TestData []map[string]interface{}
|
||||
|
||||
func SetupTestTable(t *testing.T, tableName string, testData TestData) *dynamodb.Client {
|
||||
func SetupTestTable(t *testing.T, tableName string, testData TestData) (*dynamodb.Client, func()) {
|
||||
t.Helper()
|
||||
ctx := context.Background()
|
||||
|
||||
|
@ -26,10 +26,6 @@ func SetupTestTable(t *testing.T, tableName string, testData TestData) *dynamodb
|
|||
dynamoClient := dynamodb.NewFromConfig(cfg,
|
||||
dynamodb.WithEndpointResolver(dynamodb.EndpointResolverFromURL("http://localhost:8000")))
|
||||
|
||||
dynamoClient.DeleteTable(ctx, &dynamodb.DeleteTableInput{
|
||||
TableName: aws.String(tableName),
|
||||
})
|
||||
|
||||
_, err = dynamoClient.CreateTable(ctx, &dynamodb.CreateTableInput{
|
||||
TableName: aws.String(tableName),
|
||||
KeySchema: []types.KeySchemaElement{
|
||||
|
@ -58,5 +54,9 @@ func SetupTestTable(t *testing.T, tableName string, testData TestData) *dynamodb
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
return dynamoClient
|
||||
return dynamoClient, func() {
|
||||
dynamoClient.DeleteTable(ctx, &dynamodb.DeleteTableInput{
|
||||
TableName: aws.String(tableName),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue