1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

improve tests

This commit is contained in:
Michael 2019-01-21 21:10:35 +01:00 committed by Carlos Alexandro Becker
parent 267145bbe4
commit d730f3e735

View File

@ -127,6 +127,43 @@ func TestUploadCustomBucketID(t *testing.T) {
assert.NoError(t, Pipe{}.Publish(ctx))
}
func TestUploadInvalidCustomBucketID(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.
assert.NoError(t, err)
var ctx = context.New(config.Project{
Dist: folder,
ProjectName: "testupload",
S3: []config.S3{
{
Bucket: "{{.Bad}}",
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.Error(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")