Skip to content

Commit

Permalink
test: deb: added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Feb 25, 2018
1 parent 20c7fa9 commit 9b70ad6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions deb/deb_test.go
Expand Up @@ -3,6 +3,7 @@ package deb
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"testing"

Expand Down Expand Up @@ -41,7 +42,8 @@ var info = nfpm.WithDefaults(nfpm.Info{
Homepage: "http://carlosbecker.com",
Vendor: "nope",
Files: map[string]string{
"../testdata/fake": "/usr/local/bin/fake",
"../testdata/fake": "/usr/local/bin/fake",
"../testdata/whatever.conf": "/usr/share/doc/fake/fake.txt",
},
ConfigFiles: map[string]string{
"../testdata/whatever.conf": "/etc/fake/fake.conf",
Expand Down Expand Up @@ -131,9 +133,13 @@ func TestConffiles(t *testing.T) {
}

func TestPathsToCreate(t *testing.T) {
assert.Equal(
t,
[]string{"usr", "usr/share", "usr/share/doc", "usr/share/doc/whatever"},
pathsToCreate("/usr/share/doc/whatever/foo.md"),
)
for path, parts := range map[string][]string{
"/usr/share/doc/whatever/foo.md": []string{"usr", "usr/share", "usr/share/doc", "usr/share/doc/whatever"},
"/var/moises": []string{"var"},
"/": []string{},
} {
t.Run(fmt.Sprintf("path: '%s'", path), func(t *testing.T) {
assert.Equal(t, parts, pathsToCreate(path))
})
}
}

0 comments on commit 9b70ad6

Please sign in to comment.