From 5e6301254ff007f2f5e13d24e83da0c57e398fef Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 13 May 2018 16:09:37 -0300 Subject: [PATCH] test: improve s3 tests --- pipeline/s3/s3.go | 2 +- pipeline/s3/s3_test.go | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pipeline/s3/s3.go b/pipeline/s3/s3.go index b089e17b1..cbdf8ec70 100644 --- a/pipeline/s3/s3.go +++ b/pipeline/s3/s3.go @@ -74,7 +74,7 @@ func upload(ctx *context.Context, conf config.S3) error { svc := s3.New(sess, &aws.Config{ Region: aws.String(conf.Region), }) - folder, err := nametemplate.Apply(ctx, "s3", conf.Folder) + folder, err := nametemplate.Apply(ctx, conf.Folder) if err != nil { return err } diff --git a/pipeline/s3/s3_test.go b/pipeline/s3/s3_test.go index c555c8f68..060c307e9 100644 --- a/pipeline/s3/s3_test.go +++ b/pipeline/s3/s3_test.go @@ -78,12 +78,20 @@ func TestUpload(t *testing.T) { Name: "bin.deb", Path: debpath, }) - start(t) - defer stop(t) + // start(t) + // defer stop(t) + setCredentials(t) assert.NoError(t, Pipe{}.Default(ctx)) assert.NoError(t, Pipe{}.Run(ctx)) } +func setCredentials(t *testing.T) { + // this comes from the testdata/config/config.json file - not real aws keys + os.Setenv("AWS_ACCESS_KEY_ID", "IWA0WZQ1QJ2I8I1ALW64") + os.Setenv("AWS_SECRET_ACCESS_KEY", "zcK4QQegvYwVGJaBm2E6k20WRLIQZqHOKOPP2npT") + os.Setenv("AWS_REGION", "us-east-1") +} + func start(t *testing.T) { dir, err := os.Getwd() assert.NoError(t, err) @@ -101,11 +109,8 @@ func start(t *testing.T) { t.FailNow() } // TODO: check if the container is healthy instead of sleeping an arbitrary amount of time + t.Log("waiting for minio to be healthy") time.Sleep(5 * time.Second) - // this comes from the testdata/config/config.json file - not real aws keys - os.Setenv("AWS_ACCESS_KEY_ID", "IWA0WZQ1QJ2I8I1ALW64") - os.Setenv("AWS_SECRET_ACCESS_KEY", "zcK4QQegvYwVGJaBm2E6k20WRLIQZqHOKOPP2npT") - os.Setenv("AWS_REGION", "us-east-1") } func stop(t *testing.T) {