mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-27 12:32:26 +02:00
improve tests
This commit is contained in:
parent
267145bbe4
commit
d730f3e735
@ -127,6 +127,43 @@ func TestUploadCustomBucketID(t *testing.T) {
|
|||||||
assert.NoError(t, Pipe{}.Publish(ctx))
|
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) {
|
func setCredentials(t *testing.T) {
|
||||||
// this comes from the testdata/config/config.json file - not real aws keys
|
// this comes from the testdata/config/config.json file - not real aws keys
|
||||||
os.Setenv("AWS_ACCESS_KEY_ID", "WPXKJC7CZQCFPKY5727N")
|
os.Setenv("AWS_ACCESS_KEY_ID", "WPXKJC7CZQCFPKY5727N")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user