Skip to content

Commit

Permalink
Add unit test for aws config
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Jan 5, 2024
1 parent a0e3fd0 commit cdd15d1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
46 changes: 46 additions & 0 deletions app/domain/model/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package model

import (
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
)

func TestNewAWSProfile(t *testing.T) { //nolint
Expand Down Expand Up @@ -74,3 +76,47 @@ func TestAWSProfileString(t *testing.T) {
})
}
}

func TestAWSConfig_Region(t *testing.T) {
t.Parallel()

type fields struct {
Config *aws.Config
}
tests := []struct {
name string
fields fields
want Region
}{
{
name: "If aws config region is ap-northeast-1, return RegionAPNortheast1",
fields: fields{
Config: &aws.Config{
Region: string(RegionAPNortheast1),
},
},
want: RegionAPNortheast1,
},
{
name: "If aws config region isempty, return RegionUSEast1",
fields: fields{
Config: &aws.Config{
Region: "",
},
},
want: RegionUSEast1,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
c := &AWSConfig{
Config: tt.fields.Config,
}
if got := c.Region(); got != tt.want {
t.Errorf("AWSConfig.Region() = %v, want %v", got, tt.want)
}
})
}
}
2 changes: 1 addition & 1 deletion app/domain/model/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ func TestS3Object_ToFile(t *testing.T) {
t.Fatalf("S3Object.ToFile() error = %v", err)
}

got, err := os.ReadFile(tmpFilePath)
got, err := os.ReadFile(filepath.Clean(tmpFilePath))
if err != nil {
t.Fatalf("os.ReadFile() error = %v", err)
}
Expand Down

0 comments on commit cdd15d1

Please sign in to comment.