From 9b70ad6db6f9a17c34b5e8e4fbfd42ac95a15099 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 25 Feb 2018 17:29:31 -0300 Subject: [PATCH] test: deb: added more tests --- deb/deb_test.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/deb/deb_test.go b/deb/deb_test.go index 6f2b6f94..c0b61e3f 100644 --- a/deb/deb_test.go +++ b/deb/deb_test.go @@ -3,6 +3,7 @@ package deb import ( "bytes" "flag" + "fmt" "io/ioutil" "testing" @@ -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", @@ -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)) + }) + } }