2017-04-14 17:15:51 +02:00
|
|
|
package context
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/config"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2017-06-22 05:09:14 +02:00
|
|
|
"golang.org/x/sync/errgroup"
|
2017-04-14 17:15:51 +02:00
|
|
|
)
|
|
|
|
|
2017-09-16 20:46:47 +02:00
|
|
|
func TestMultipleAdds(t *testing.T) {
|
2017-04-14 17:15:51 +02:00
|
|
|
var assert = assert.New(t)
|
2017-09-16 20:46:47 +02:00
|
|
|
var artifacts = []string{
|
2017-04-14 17:15:51 +02:00
|
|
|
"dist/a",
|
|
|
|
"dist/b",
|
|
|
|
"dist/c",
|
|
|
|
"dist/d",
|
|
|
|
}
|
2017-09-16 20:46:47 +02:00
|
|
|
var dockerfiles = []string{
|
|
|
|
"a/b:1.0.0",
|
|
|
|
"c/d:2.0.0",
|
|
|
|
"e/f:3.0.0",
|
|
|
|
}
|
2017-04-14 17:15:51 +02:00
|
|
|
var ctx = New(config.Project{
|
|
|
|
Dist: "dist",
|
|
|
|
})
|
|
|
|
var g errgroup.Group
|
2017-09-16 20:46:47 +02:00
|
|
|
for _, f := range artifacts {
|
2017-04-14 17:15:51 +02:00
|
|
|
f := f
|
|
|
|
g.Go(func() error {
|
|
|
|
ctx.AddArtifact(f)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
assert.NoError(g.Wait())
|
2017-09-16 20:46:47 +02:00
|
|
|
for _, d := range dockerfiles {
|
|
|
|
d := d
|
|
|
|
g.Go(func() error {
|
|
|
|
ctx.AddDocker(d)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
assert.NoError(g.Wait())
|
|
|
|
assert.Len(ctx.Artifacts, len(artifacts))
|
2017-04-14 17:15:51 +02:00
|
|
|
assert.Contains(ctx.Artifacts, "a", "b", "c", "d")
|
2017-09-16 20:46:47 +02:00
|
|
|
assert.Len(ctx.Dockers, len(dockerfiles))
|
|
|
|
assert.Contains(ctx.Dockers, "a/b:1.0.0", "c/d:2.0.0", "e/f:3.0.0")
|
2017-04-14 17:15:51 +02:00
|
|
|
}
|
2017-07-02 02:34:32 +02:00
|
|
|
|
2017-07-14 00:46:48 +02:00
|
|
|
func TestMultipleBinaryAdds(t *testing.T) {
|
2017-07-02 02:34:32 +02:00
|
|
|
var assert = assert.New(t)
|
|
|
|
var list = map[string]string{
|
2017-07-14 00:46:48 +02:00
|
|
|
"a": "folder/a",
|
|
|
|
"b": "folder/b",
|
|
|
|
"c": "folder/c",
|
|
|
|
"d": "folder/d",
|
2017-07-02 02:34:32 +02:00
|
|
|
}
|
|
|
|
var ctx = New(config.Project{
|
|
|
|
Dist: "dist",
|
|
|
|
})
|
|
|
|
var g errgroup.Group
|
|
|
|
for k, f := range list {
|
|
|
|
f := f
|
|
|
|
k := k
|
|
|
|
g.Go(func() error {
|
2017-07-14 01:43:12 +02:00
|
|
|
ctx.AddBinary("linuxamd64", k, k, f)
|
2017-07-02 02:34:32 +02:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
assert.NoError(g.Wait())
|
2017-07-14 00:46:48 +02:00
|
|
|
assert.Len(ctx.Binaries["linuxamd64"], len(list))
|
|
|
|
assert.Len(ctx.Binaries, 1)
|
2017-07-02 02:34:32 +02:00
|
|
|
}
|