You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-05 00:59:04 +02:00
test: testing log output as well
This commit is contained in:
@ -1,8 +1,11 @@
|
|||||||
package nametemplate
|
package nametemplate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/apex/log"
|
||||||
|
"github.com/apex/log/handlers/cli"
|
||||||
"github.com/goreleaser/goreleaser/config"
|
"github.com/goreleaser/goreleaser/config"
|
||||||
"github.com/goreleaser/goreleaser/context"
|
"github.com/goreleaser/goreleaser/context"
|
||||||
"github.com/goreleaser/goreleaser/internal/artifact"
|
"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.EqualError(t, err, `template: archive_name:1: unexpected "}" in operand`)
|
||||||
assert.Empty(t, s)
|
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")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user