1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/defaults/defaults_test.go

73 lines
1.5 KiB
Go
Raw Normal View History

2017-01-14 18:29:01 +02:00
package defaults
import (
"testing"
2017-01-15 00:01:32 +02:00
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
2017-01-14 18:29:01 +02:00
"github.com/stretchr/testify/assert"
)
func TestFillBasicData(t *testing.T) {
assert := assert.New(t)
var ctx = &context.Context{
2017-01-18 19:08:48 +02:00
Config: config.Project{},
2017-01-14 18:29:01 +02:00
}
assert.NoError(Pipe{}.Run(ctx))
2017-01-18 19:08:48 +02:00
assert.Equal("goreleaser/goreleaser", ctx.Config.Release.Repo)
assert.Equal("goreleaser", ctx.Config.Build.BinaryName)
assert.Equal(".", ctx.Config.Build.Main)
2017-01-18 19:08:48 +02:00
assert.Equal("tar.gz", ctx.Config.Archive.Format)
assert.Contains(ctx.Config.Build.Goos, "darwin")
assert.Contains(ctx.Config.Build.Goos, "linux")
assert.Contains(ctx.Config.Build.Goarch, "386")
assert.Contains(ctx.Config.Build.Goarch, "amd64")
assert.Contains(ctx.Config.Brew.Install, "bin.install \"goreleaser\"")
2017-01-14 18:38:48 +02:00
assert.NotEmpty(
2017-01-18 19:08:48 +02:00
ctx.Config.Archive.Replacements,
ctx.Config.Archive.NameTemplate,
ctx.Config.Build.Ldflags,
ctx.Config.Archive.Files,
2017-01-14 18:38:48 +02:00
)
}
func TestFilesFilled(t *testing.T) {
assert := assert.New(t)
2017-01-18 19:08:48 +02:00
var ctx = &context.Context{
Config: config.Project{
Archive: config.Archive{
Files: []string{
"README.md",
},
2017-01-14 23:52:39 +02:00
},
2017-01-14 18:38:48 +02:00
},
}
assert.NoError(Pipe{}.Run(ctx))
2017-01-18 19:08:48 +02:00
assert.Len(ctx.Config.Archive.Files, 1)
2017-01-14 18:38:48 +02:00
}
func TestAcceptFiles(t *testing.T) {
var files = []string{
"LICENSE.md",
2017-01-14 19:17:03 +02:00
"LIceNSE.txt",
2017-01-14 18:38:48 +02:00
"LICENSE",
"LICENCE.txt",
2017-01-14 19:17:03 +02:00
"LICEncE",
2017-01-14 18:38:48 +02:00
"README",
2017-01-14 19:17:03 +02:00
"READme.md",
2017-01-14 18:38:48 +02:00
"CHANGELOG.txt",
2017-01-14 19:17:03 +02:00
"ChanGELOG.md",
2017-01-14 18:38:48 +02:00
}
for _, file := range files {
t.Run(file, func(t *testing.T) {
assert.True(t, accept(file))
})
2017-01-14 18:38:48 +02:00
}
2017-01-14 18:29:01 +02:00
}