1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-05-24 05:56:16 +02:00

test: added some more

This commit is contained in:
Carlos Alexandro Becker 2018-02-16 19:11:52 -02:00
parent 00335c9c83
commit e5fe548add
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
3 changed files with 85 additions and 2 deletions

View File

@ -81,7 +81,10 @@ func createDataTarGz(now time.Time, info nfpm.Info) (dataTarGz, md5sums []byte,
defer compress.Close() // nolint: errcheck
var md5buf bytes.Buffer
for _, files := range []map[string]string{info.Files, info.ConfigFiles} {
for _, files := range []map[string]string{
info.Files,
info.ConfigFiles,
} {
for src, dst := range files {
size, err := copyToTarAndDigest(out, &md5buf, now, src, dst)
if err != nil {

View File

@ -24,7 +24,9 @@ func TestDeb(t *testing.T) {
Homepage: "http://carlosbecker.com",
Vendor: "nope",
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
"../testdata/fake": "/usr/local/bin/fake",
},
ConfigFiles: map[string]string{
"../testdata/whatever.conf": "/etc/fake/fake.conf",
},
}),
@ -32,3 +34,56 @@ func TestDeb(t *testing.T) {
)
assert.NoError(t, err)
}
func TestDebFileDoesNotExist(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",
Files: map[string]string{
"../testdata/": "/usr/local/bin/fake",
},
ConfigFiles: map[string]string{
"../testdata/whatever.confzzz": "/etc/fake/fake.conf",
},
}),
ioutil.Discard,
)
assert.Error(t, err)
}
func TestDebNoFiles(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",
}),
ioutil.Discard,
)
assert.NoError(t, err)
}
func TestDebNoInfo(t *testing.T) {
var err = Default.Package(nfpm.WithDefaults(nfpm.Info{}), ioutil.Discard)
assert.NoError(t, err)
}

View File

@ -36,3 +36,28 @@ func TestRPM(t *testing.T) {
)
assert.NoError(t, err)
}
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",
Files: map[string]string{},
ConfigFiles: map[string]string{},
}),
ioutil.Discard,
)
assert.Error(t, err)
}