mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix: added nfpm validations
This commit is contained in:
parent
c56e2dff2f
commit
66019fc509
4
Gopkg.lock
generated
4
Gopkg.lock
generated
@ -97,8 +97,8 @@
|
||||
"glob",
|
||||
"rpm"
|
||||
]
|
||||
revision = "c52d07bcc82976b0206e6ab8dc9c12a23e1b142e"
|
||||
version = "v0.6.2"
|
||||
revision = "672aa2bd659a22558aa5d727bd6e76ec5d3aafb2"
|
||||
version = "v0.6.3"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/masterminds/semver"
|
||||
|
@ -121,6 +121,10 @@ func create(ctx *context.Context, format, arch string, binaries []artifact.Artif
|
||||
ConfigFiles: ctx.Config.NFPM.ConfigFiles,
|
||||
}
|
||||
|
||||
if err := nfpm.Validate(info); err != nil {
|
||||
return errors.Wrap(err, "invalid nfpm config")
|
||||
}
|
||||
|
||||
packager, err := nfpm.Get(format)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -31,6 +31,7 @@ func TestRunPipeNoFormats(t *testing.T) {
|
||||
|
||||
func TestRunPipeInvalidFormat(t *testing.T) {
|
||||
var ctx = context.New(config.Project{
|
||||
ProjectName: "nope",
|
||||
NFPM: config.NFPM{
|
||||
Bindir: "/usr/bin",
|
||||
NameTemplate: defaultNameTemplate,
|
||||
@ -38,6 +39,9 @@ func TestRunPipeInvalidFormat(t *testing.T) {
|
||||
Files: map[string]string{},
|
||||
},
|
||||
})
|
||||
ctx.Git = context.GitInfo{
|
||||
CurrentTag: "v1.2.3",
|
||||
}
|
||||
for _, goos := range []string{"linux", "darwin"} {
|
||||
for _, goarch := range []string{"amd64", "386"} {
|
||||
ctx.Artifacts.Add(artifact.Artifact{
|
||||
@ -128,7 +132,8 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var ctx = context.New(config.Project{
|
||||
Dist: dist,
|
||||
Dist: dist,
|
||||
ProjectName: "asd",
|
||||
NFPM: config.NFPM{
|
||||
Formats: []string{"deb", "rpm"},
|
||||
Files: map[string]string{
|
||||
@ -136,7 +141,9 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
ctx.Version = "1.0.0"
|
||||
ctx.Git = context.GitInfo{
|
||||
CurrentTag: "v1.2.3",
|
||||
}
|
||||
ctx.Artifacts.Add(artifact.Artifact{
|
||||
Name: "mybin",
|
||||
Path: filepath.Join(dist, "mybin", "mybin"),
|
||||
@ -147,6 +154,28 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
||||
assert.Contains(t, Pipe{}.Run(ctx).Error(), `dist/mybin/mybin: file does not exist`)
|
||||
}
|
||||
|
||||
func TestInvalidConfig(t *testing.T) {
|
||||
folder, err := ioutil.TempDir("", "archivetest")
|
||||
assert.NoError(t, err)
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
assert.NoError(t, os.Mkdir(dist, 0755))
|
||||
assert.NoError(t, os.Mkdir(filepath.Join(dist, "mybin"), 0755))
|
||||
var ctx = context.New(config.Project{
|
||||
Dist: dist,
|
||||
NFPM: config.NFPM{
|
||||
Formats: []string{"deb"},
|
||||
},
|
||||
})
|
||||
ctx.Artifacts.Add(artifact.Artifact{
|
||||
Name: "mybin",
|
||||
Path: filepath.Join(dist, "mybin", "mybin"),
|
||||
Goos: "linux",
|
||||
Goarch: "amd64",
|
||||
Type: artifact.Binary,
|
||||
})
|
||||
assert.Contains(t, Pipe{}.Run(ctx).Error(), `invalid nfpm config: package name cannot be empty`)
|
||||
}
|
||||
|
||||
func TestDefault(t *testing.T) {
|
||||
var ctx = &context.Context{
|
||||
Config: config.Project{
|
||||
|
Loading…
x
Reference in New Issue
Block a user