Skip to content

Commit fdf2e2c

Browse files
author
Aaron Schlesinger
committed
fix(pkg/cleaner/cleaner_test.go): add basic unit tests for the cleaner
1 parent d98eb49 commit fdf2e2c

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

pkg/cleaner/cleaner_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cleaner
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
"strings"
7+
"testing"
8+
9+
"github.com/arschles/assert"
10+
"k8s.io/kubernetes/pkg/api"
11+
)
12+
13+
func TestGetDisjunction(t *testing.T) {
14+
nsList := []api.Namespace{
15+
api.Namespace{ObjectMeta: api.ObjectMeta{Name: "app1"}},
16+
api.Namespace{ObjectMeta: api.ObjectMeta{Name: "app2"}},
17+
}
18+
dirList := []string{"app1", "app3"}
19+
disj := getDisjunction(nsList, dirList)
20+
assert.Equal(t, len(disj), 2, "number of items in the disjunction")
21+
}
22+
23+
func TestLocalDirs(t *testing.T) {
24+
wd, err := os.Getwd()
25+
assert.NoErr(t, err)
26+
pkgDir, err := filepath.Abs(wd + "/..")
27+
assert.NoErr(t, err)
28+
lDirs, err := localDirs(pkgDir)
29+
for _, dir := range lDirs {
30+
rel, err := filepath.Rel(pkgDir, dir)
31+
assert.NoErr(t, err)
32+
spl := strings.Split(rel, "/")
33+
assert.Equal(t, len(spl), 1, "directory depth")
34+
}
35+
}

0 commit comments

Comments
 (0)