-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store driver name is now a parameter on Store class. It make possible to test some aspects of store class. Also, unit tests included.
- Loading branch information
Showing
3 changed files
with
71 additions
and
16 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
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,33 @@ | ||
package store | ||
|
||
import "testing" | ||
|
||
func TestStoreEmptyDriver(t *testing.T) { | ||
exp := "Driver name cannot be empty. Use .Default method instead" | ||
_, err := New("") | ||
|
||
if err.Error() != exp { | ||
t.Errorf("Expected error \"%v\" and got \"%v\".", exp, err) | ||
} | ||
} | ||
|
||
func TestStoreInvalidDriver(t *testing.T) { | ||
exp := "Driver does not exists" | ||
_, err := New("nonono") | ||
|
||
if err.Error() != exp { | ||
t.Errorf("Expected error \"%v\" and got \"%v\".", exp, err) | ||
} | ||
} | ||
|
||
func TestStoreDefaultDriver(t *testing.T) { | ||
exp := "memory" | ||
store, err := Default() | ||
if err != nil { | ||
t.Errorf("Error \"%v\".", err) | ||
} | ||
if store.driverName != exp { | ||
t.Errorf("Expected driver \"%v\" and got \"%v\".", exp, store.driverName) | ||
} | ||
defer store.Close() | ||
} |