From ee745dab768a5c881568b039c3d7ab5da3937f94 Mon Sep 17 00:00:00 2001 From: HenryAtUber Date: Tue, 5 May 2020 08:58:47 -0700 Subject: [PATCH 1/2] url.Parse's result has a slash as the prefix in the Path member variable --- go/config.go | 6 +++++- go/config_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/go/config.go b/go/config.go index ddf7cba..16e5439 100644 --- a/go/config.go +++ b/go/config.go @@ -268,7 +268,11 @@ func (c *Config) GetUser() string { // GetOutputBucket is getter of OutputBucket. func (c *Config) GetOutputBucket() string { - return c.dsn.Scheme + "://" + c.dsn.Host + "/" + c.dsn.Path + if strings.HasPrefix(c.dsn.Path, "/") { + return c.dsn.Scheme + "://" + c.dsn.Host + c.dsn.Path + } else { + return c.dsn.Scheme + "://" + c.dsn.Host + "/" + c.dsn.Path + } } // GetWorkgroup is getter of Workgroup. diff --git a/go/config_test.go b/go/config_test.go index 5a5bd07..dda8759 100644 --- a/go/config_test.go +++ b/go/config_test.go @@ -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() From 4f9b9a143b55d8eb034db90a92c58ee405d75e7c Mon Sep 17 00:00:00 2001 From: HenryAtUber Date: Tue, 5 May 2020 09:02:39 -0700 Subject: [PATCH 2/2] fix lint error --- go/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go/config.go b/go/config.go index 16e5439..42b822c 100644 --- a/go/config.go +++ b/go/config.go @@ -270,9 +270,8 @@ func (c *Config) GetUser() string { func (c *Config) GetOutputBucket() string { if strings.HasPrefix(c.dsn.Path, "/") { return c.dsn.Scheme + "://" + c.dsn.Host + c.dsn.Path - } else { - return c.dsn.Scheme + "://" + c.dsn.Host + "/" + c.dsn.Path } + return c.dsn.Scheme + "://" + c.dsn.Host + "/" + c.dsn.Path } // GetWorkgroup is getter of Workgroup.