Example Mock Unit Test for Redis in Golang
Your project directory structure should look like this
+ your_gopath/
|
+--+ src/github.com/moemoe89
| |
| +--+ go-unit-test-redis/
| |
| +--+ main.go
| + repository/
| |
| +--+ repository.go
| + repository_test.go
|
+--+ bin/
| |
| +-- ... executable file
|
+--+ pkg/
|
+-- ... all dependency_library required
- Setup Golang https://golang.org
- Under
$GOPATH
, do the following command :
$ mkdir -p src/github.com/moemoe89
$ cd src/github.com/moemoe89
$ git clone <url>
$ mv <cloned directory> go-unit-test-redis
$ go test ./...
MIT