cleaned up some logic, using filepath library when working with paths to have better support for windows (per @chrhlnd pull request). added tests to test looking for empty files/directories

This commit is contained in:
Steve Domino
2015-10-19 15:01:40 -06:00
parent a117d7d71e
commit 9d6df7eff7
2 changed files with 103 additions and 62 deletions
+24
View File
@@ -65,6 +65,7 @@ func TestNew(t *testing.T) {
//
func TestWrite(t *testing.T) {
createFriend(t)
teardown()
}
//
@@ -78,6 +79,18 @@ func TestRead(t *testing.T) {
if friend0.Name == "" {
t.Error("Expected friend, have none")
}
teardown()
}
//
func TestReadEmpty(t *testing.T) {
if err := db.Read(friendsPath+"/friend1", &friend0); err == nil {
t.Error("Expected nothing, found friend")
}
teardown()
}
//
@@ -96,6 +109,17 @@ func TestReadall(t *testing.T) {
teardown()
}
//
func TestReadallEmpty(t *testing.T) {
friends := []Friend{}
if err := db.Read(friendsPath, &friends); err == nil {
t.Error("Expected nothing, found friends")
}
teardown()
}
//
func TestDelete(t *testing.T) {
createFriend(t)