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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user