|
1 | 1 | package utils |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "sort" |
| 5 | + "strings" |
4 | 6 | "testing" |
5 | 7 |
|
6 | 8 | . "github.com/smartystreets/goconvey/convey" |
@@ -42,3 +44,43 @@ func TestPathToTARPathparts(t *testing.T) { |
42 | 44 | So([]string{"/long/path/to", "dir"}, ShouldResemble, []string{dir, base}) |
43 | 45 | }) |
44 | 46 | } |
| 47 | + |
| 48 | +func TestRemoveDuplicates(t *testing.T) { |
| 49 | + Convey("Testing RemoveDuplicates()", t, func() { |
| 50 | + slice := RemoveDuplicates([]string{"a", "b", "c", "a"}) |
| 51 | + sort.Strings(slice) |
| 52 | + So(slice, ShouldResemble, []string{"a", "b", "c"}) |
| 53 | + |
| 54 | + slice = RemoveDuplicates([]string{"a", "b", "c", "a"}) |
| 55 | + sort.Strings(slice) |
| 56 | + So(slice, ShouldResemble, []string{"a", "b", "c"}) |
| 57 | + |
| 58 | + slice = RemoveDuplicates([]string{"a", "b", "c", "a", "a", "b", "d"}) |
| 59 | + sort.Strings(slice) |
| 60 | + So(slice, ShouldResemble, []string{"a", "b", "c", "d"}) |
| 61 | + |
| 62 | + slice = RemoveDuplicates([]string{"a", "b", "c", "a", ""}) |
| 63 | + sort.Strings(slice) |
| 64 | + So(slice, ShouldResemble, []string{"", "a", "b", "c"}) |
| 65 | + }) |
| 66 | +} |
| 67 | + |
| 68 | +func TestGetHomeDir(t *testing.T) { |
| 69 | + Convey("Testing GetHomeDir()", t, func() { |
| 70 | + homedir, err := GetHomeDir() |
| 71 | + So(err, ShouldBeNil) |
| 72 | + So(homedir, ShouldNotEqual, "") |
| 73 | + }) |
| 74 | +} |
| 75 | + |
| 76 | +func TestGetConfigFilePath(t *testing.T) { |
| 77 | + Convey("Testing GetConfigFilePath()", t, func() { |
| 78 | + configPath, err := GetConfigFilePath() |
| 79 | + So(err, ShouldBeNil) |
| 80 | + So(configPath, ShouldNotEqual, "") |
| 81 | + |
| 82 | + homedir, err := GetHomeDir() |
| 83 | + So(err, ShouldBeNil) |
| 84 | + So(strings.Contains(configPath, homedir), ShouldBeTrue) |
| 85 | + }) |
| 86 | +} |
0 commit comments