| 1 |
# Samples |
| 2 |
|
| 3 |
This directory contains an example of a package containing a non-trivial |
| 4 |
interface that can be mocked with GoMock. The interesting files are: |
| 5 |
|
| 6 |
* `user.go`: Source code for the sample package, containing interfaces to be |
| 7 |
mocked. This file depends on the packages named imp[1-4] for various things. |
| 8 |
|
| 9 |
* `user_test.go`: A test for the sample package, in which mocks of the |
| 10 |
interfaces from `user.go` are used. This demonstrates how to create mock |
| 11 |
objects, set up expectations, and so on. |
| 12 |
|
| 13 |
* `mock_user_test.go`: The generated mock code. See ../gomock/matchers.go |
| 14 |
for the `go:generate` command used to generate it. |
| 15 |
|
| 16 |
To run the test, |
| 17 |
|
| 18 |
```bash |
| 19 |
go test github.com/golang/mock/sample |
| 20 |
``` |