Last active
December 22, 2021 14:42
-
-
Save Jimeux/9c18d890075e9042406484ee7726401e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestHandler(t *testing.T) { | |
logger = ws.NewNopLogger() | |
t.Run("returns 200 on successful save", func(t *testing.T) { | |
ddb := &awsiface.MockDDB{} | |
ddb.PutItemFn = func(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error) { | |
return &dynamodb.PutItemOutput{}, nil | |
} | |
repo := ws.NewRepository(ddb, "connections") | |
svc = ws.NewWebSocketService(nil, repo) | |
res, err := handler(context.Background(), &events.APIGatewayWebsocketProxyRequest{}) | |
if err != nil { | |
t.Fatalf("unexpected error: %+v", err) | |
} | |
if res.StatusCode != http.StatusOK { | |
t.Fatalf("did not return valid response: got %d but expected %d", res.StatusCode, http.StatusOK) | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment