Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Malformed S3 URL test #380

Merged
merged 1 commit into from Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions s3/get_s3_test.go
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"
"os"
"path/filepath"
"strings"
"testing"

"github.com/aws/aws-sdk-go/aws/awserr"
Expand Down Expand Up @@ -226,6 +227,34 @@ func TestGetter_Mode_collision(t *testing.T) {
}
}

func TestGetAny_S3_malformed(t *testing.T) {
ctx := context.Background()

g := new(Getter)
dst := testing_helper.TempTestFile(t)
defer os.RemoveAll(filepath.Dir(dst))

req := &getter.Request{
Src: "s3::https://s3-eu-west-2.amazonaws.com/picat-was-here//malformed",
Dst: dst,
GetMode: getter.ModeFile,
}

c := getter.Client{
Getters: []getter.Getter{g},
}

_, err := c.Get(ctx, req)
if err == nil {
t.Fatalf("expected error, got none")
}

expectedErrMsg := "URL is not a valid S3 URL"
if !strings.Contains(err.Error(), expectedErrMsg) {
t.Fatalf("expected %q error, but got %v", expectedErrMsg, err)
}
}

func TestGetter_Url(t *testing.T) {
var s3tests = []struct {
name string
Expand Down