mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
test: testing log output as well
This commit is contained in:
parent
449ec3f49b
commit
65d3c7ad7f
@ -1,8 +1,11 @@
|
||||
package nametemplate
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/apex/log/handlers/cli"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
||||
@ -50,3 +53,31 @@ func TestInvalidNameTemplate(t *testing.T) {
|
||||
assert.EqualError(t, err, `template: archive_name:1: unexpected "}" in operand`)
|
||||
assert.Empty(t, s)
|
||||
}
|
||||
|
||||
func TestDeprecatedFieldOnNameTemplate(t *testing.T) {
|
||||
for _, temp := range []string{
|
||||
"{{.Binary}}",
|
||||
"{{ .Binary}}",
|
||||
"{{.Binary }}",
|
||||
"{{ .Binary }}",
|
||||
} {
|
||||
t.Run(temp, func(tt *testing.T) {
|
||||
var out bytes.Buffer
|
||||
log.SetHandler(cli.New(&out))
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "proj",
|
||||
Archive: config.Archive{
|
||||
NameTemplate: temp,
|
||||
},
|
||||
})
|
||||
s, err := Apply(ctx, artifact.Artifact{
|
||||
Goos: "windows",
|
||||
Goarch: "amd64",
|
||||
Name: "winbin",
|
||||
}, "bin")
|
||||
assert.NoError(tt, err)
|
||||
assert.Equal(tt, "bin", s)
|
||||
assert.Contains(tt, out.String(), "you are using a deprecated field on your template")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user