Skip to content
Permalink
Browse files

feat: add tests

  • Loading branch information...
mmatur authored and caarlos0 committed Jan 21, 2019
1 parent 0aa80ec commit 203066ffa0ce1398d8a5c7e6dc281fe8c09cd3fe
Showing with 38 additions and 0 deletions.
  1. +38 −0 internal/pipe/s3/s3_test.go
@@ -89,6 +89,44 @@ func TestUpload(t *testing.T) {
assert.NoError(t, Pipe{}.Publish(ctx))
}

func TestUploadCustomBucketID(t *testing.T) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)
tgzpath := filepath.Join(folder, "bin.tar.gz")
debpath := filepath.Join(folder, "bin.deb")
assert.NoError(t, ioutil.WriteFile(tgzpath, []byte("fake\ntargz"), 0744))
assert.NoError(t, ioutil.WriteFile(debpath, []byte("fake\ndeb"), 0744))
// Set custom BUCKET_ID env variable.
err = os.Setenv("BUCKET_ID", "test")
assert.NoError(t, err)
var ctx = context.New(config.Project{
Dist: folder,
ProjectName: "testupload",
S3: []config.S3{
{
Bucket: "{{.Env.BUCKET_ID}}",
Endpoint: "http://localhost:9000",
},
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
ctx.Artifacts.Add(artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
})
start(t)
defer stop(t)
setCredentials(t)
assert.NoError(t, Pipe{}.Default(ctx))
assert.NoError(t, Pipe{}.Publish(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", "WPXKJC7CZQCFPKY5727N")

0 comments on commit 203066f

Please sign in to comment.
You can’t perform that action at this time.