This file contains 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 (m *DynamodbMockClient) GetItem(input *dynamodb.GetItemInput) ( | |
*dynamodb.GetItemOutput, | |
error, | |
) { | |
var err = errors.New("player not found") | |
val, ok := input.Key["PlayerName"] | |
if ok { | |
err = nil | |
switch *val.S { |
This file contains 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
package middleware | |
import ( | |
"fmt" | |
"aws-golang-lambda/pkg/jwtparser" | |
"github.com/gin-gonic/gin" | |
) |
This file contains 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
package main | |
import ( | |
"context" | |
"os" | |
"aws-golang-lambda/api/handler" | |
"aws-golang-lambda/usecase/users" | |
mysqldb "aws-golang-lambda/repository/mysql" |
This file contains 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
package mysql | |
type Users struct { | |
Address string `db:"address"` | |
FirstName string `db:"first_name"` | |
LastName string `db:"last_name"` | |
Password string `db:"password"` | |
Username string `db:"username"` | |
} |
This file contains 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
package ddb | |
import ( | |
"fmt" | |
"aws-golang-lambda/entity" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/service/dynamodb" | |
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" |
This file contains 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
package main | |
import ( | |
"fmt" | |
"testing" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/service/dynamodb" | |
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" | |
"github.com/stretchr/testify/assert" |
This file contains 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
package main | |
import ( | |
"fmt" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/dynamodb" | |
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" | |
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" |
This file contains 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
#!/bin/bash | |
aws dynamodb create-table \ | |
--table-name SanAntonioSpurs \ | |
--attribute-definitions AttributeName=PlayerName,AttributeType=S AttributeName=JerseyNumber,AttributeType=N \ | |
--key-schema AttributeName=PlayerName,KeyType=HASH AttributeName=JerseyNumber,KeyType=RANGE \ | |
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 | |
aws dynamodb put-item --table-name SanAntonioSpurs --item "{\"PlayerName\":{\"S\":\"Manu Ginobili\"},\"JerseyNumber\":{\"N\":\"20\"}, \"Position\":{\"S\":\"Shooting Guard\"}}" |
This file contains 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
import logging | |
import boto3 | |
from botocore.exceptions import ClientError, ParamValidationError | |
dynamodb2 = boto3.resource('dynamodb') | |
def get_from_dynamodb(table, key): | |
try: |
This file contains 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
import pytest | |
import boto3 | |
from botocore.exceptions import ClientError, ParamValidationError | |
from moto import mock_dynamodb2 | |
from dynamodb_get_item import get_from_dynamodb | |
@mock_dynamodb2 | |
def test_get_from_dynamodb(): |