2018-02-03 20:42:56 +01:00
|
|
|
package rpm
|
|
|
|
|
|
|
|
import (
|
2018-02-12 22:15:37 +01:00
|
|
|
"io/ioutil"
|
2018-02-16 23:50:13 +01:00
|
|
|
"os"
|
2018-02-03 20:42:56 +01:00
|
|
|
"testing"
|
|
|
|
|
2018-02-05 02:53:22 +01:00
|
|
|
"github.com/goreleaser/nfpm"
|
2018-02-05 03:54:03 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
2018-02-03 20:42:56 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRPM(t *testing.T) {
|
2018-02-12 22:15:37 +01:00
|
|
|
var err = Default.Package(
|
|
|
|
nfpm.WithDefaults(nfpm.Info{
|
|
|
|
Name: "foo",
|
|
|
|
Arch: "amd64",
|
2018-02-03 20:42:56 +01:00
|
|
|
Depends: []string{
|
|
|
|
"bash",
|
|
|
|
},
|
|
|
|
Description: "Foo does things",
|
|
|
|
Priority: "extra",
|
|
|
|
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
|
|
|
Version: "1.0.0",
|
|
|
|
Section: "default",
|
|
|
|
Homepage: "http://carlosbecker.com",
|
|
|
|
Vendor: "nope",
|
2018-02-05 00:00:20 +01:00
|
|
|
License: "MIT",
|
2018-02-12 19:29:44 +01:00
|
|
|
Bindir: "/usr/local/bin",
|
2018-02-03 20:42:56 +01:00
|
|
|
Files: map[string]string{
|
2018-02-05 02:36:02 +01:00
|
|
|
"../testdata/fake": "/usr/local/bin/fake",
|
2018-02-05 00:19:00 +01:00
|
|
|
},
|
|
|
|
ConfigFiles: map[string]string{
|
2018-02-05 02:36:02 +01:00
|
|
|
"../testdata/whatever.conf": "/etc/fake/fake.conf",
|
2018-02-03 20:42:56 +01:00
|
|
|
},
|
2018-02-12 22:15:37 +01:00
|
|
|
}),
|
|
|
|
ioutil.Discard,
|
2018-02-03 20:42:56 +01:00
|
|
|
)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2018-02-16 22:11:52 +01:00
|
|
|
|
|
|
|
func TestNoFiles(t *testing.T) {
|
|
|
|
var err = Default.Package(
|
|
|
|
nfpm.WithDefaults(nfpm.Info{
|
|
|
|
Name: "foo",
|
|
|
|
Arch: "amd64",
|
|
|
|
Depends: []string{
|
|
|
|
"bash",
|
|
|
|
},
|
|
|
|
Description: "Foo does things",
|
|
|
|
Priority: "extra",
|
|
|
|
Maintainer: "Carlos A Becker <pkg@carlosbecker.com>",
|
|
|
|
Version: "1.0.0",
|
|
|
|
Section: "default",
|
|
|
|
Homepage: "http://carlosbecker.com",
|
|
|
|
Vendor: "nope",
|
|
|
|
License: "MIT",
|
|
|
|
Bindir: "/usr/local/bin",
|
|
|
|
}),
|
|
|
|
ioutil.Discard,
|
|
|
|
)
|
|
|
|
assert.Error(t, err)
|
|
|
|
}
|
2018-02-16 23:50:13 +01:00
|
|
|
|
|
|
|
func TestRPMBuildNotInPath(t *testing.T) {
|
|
|
|
assert.NoError(t, os.Setenv("PATH", ""))
|
|
|
|
var err = Default.Package(
|
|
|
|
nfpm.WithDefaults(nfpm.Info{}),
|
|
|
|
ioutil.Discard,
|
|
|
|
)
|
|
|
|
assert.EqualError(t, err, `rpmbuild failed: exec: "rpmbuild": executable file not found in $PATH`)
|
|
|
|
}
|