Skip to content

Commit

Permalink
Merge pull request #9 from uber/henry.wu/url_parse_path_has_slash_prefix
Browse files Browse the repository at this point in the history
url.Parse's result has a slash as the prefix in the Path member variable
  • Loading branch information
henrywu2019 committed May 5, 2020
2 parents 9e9c7d4 + 4f9b9a1 commit 8618706
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ func (c *Config) GetUser() string {

// GetOutputBucket is getter of OutputBucket.
func (c *Config) GetOutputBucket() string {
if strings.HasPrefix(c.dsn.Path, "/") {
return c.dsn.Scheme + "://" + c.dsn.Host + c.dsn.Path
}
return c.dsn.Scheme + "://" + c.dsn.Host + "/" + c.dsn.Path
}

Expand Down
10 changes: 10 additions & 0 deletions go/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func TestAthenaConfig(t *testing.T) {
assert.Nil(t, err)
}

func TestGetOutputBucket(t *testing.T) {
var s3bucket string = "s3://query-results-henry-wu-us-east-2/local/"
testConf := NewNoOpsConfig()
err := testConf.SetOutputBucket(s3bucket)
conf, _ := NewConfig(testConf.Stringify())
assert.Nil(t, err)
assert.Equal(t, testConf.GetOutputBucket(), "s3://query-results-henry-wu-us-east-2/local/")
assert.Equal(t, conf.GetOutputBucket(), "s3://query-results-henry-wu-us-east-2/local/")
}

func TestAthenaConfigWrongS3Bucket(t *testing.T) {
var s3bucket string = "file:///query-results-henry-wu-us-east-2/"
testConf := NewNoOpsConfig()
Expand Down

0 comments on commit 8618706

Please sign in to comment.