This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ unit tests
- Loading branch information
Pedro Cunha
committed
Oct 13, 2017
1 parent
3309911
commit b4e255d
Showing
5 changed files
with
77 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package data | ||
|
||
import ( | ||
"github.com/spf13/afero" | ||
"reflect" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestFilesToKeys(t *testing.T) { | ||
AppFs = afero.NewMemMapFs() | ||
AppFs.MkdirAll("src/", 0755) | ||
afero.WriteFile(AppFs, "src/a/b", []byte("file c"), 0644) | ||
afero.WriteFile(AppFs, "src/c", []byte("file c"), 0644) | ||
|
||
list := filesToKeys("src") | ||
expectation := []string{ | ||
"src/a/b", | ||
"src/c", | ||
} | ||
|
||
if !reflect.DeepEqual(list, expectation) { | ||
t.Errorf("list is different got: %s, want: %s.", strings.Join(list, ","), strings.Join(expectation, ",")) | ||
} | ||
} | ||
|
||
func TestFilesToKeysWhenEmptyFolder(t *testing.T) { | ||
AppFs = afero.NewMemMapFs() | ||
AppFs.MkdirAll("src", 0755) | ||
|
||
list := filesToKeys("src") | ||
|
||
if len(list) != 0 { | ||
t.Errorf("expecting empty list but got: %s", strings.Join(list, ",")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters