Skip to content

Commit a23f449

Browse files
author
Dwayne Schultz
committed
Fixup demo line numbers
1 parent f501dec commit a23f449

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ type IsFavorite func(n int) bool
2121
## Using mocks
2222

2323
### Creating a mock instance
24-
Code generation creates a `newMockXXX` function for each mock you generate. Simply [invoke the function and hold on to the mock](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L13-L14) for further testing:
24+
Code generation creates a `newMockXXX` function for each mock you generate. Simply [invoke the function and hold on to the mock](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L14-L15) for further testing:
2525
```go
2626
isFavMock := newMockIsFavorite(t, nil)
2727
writerMock := newMockWriter(t, nil)
2828
```
2929

3030
### Expectations
31-
To get a mock to perform specific behaviors, you have to tell it what to expect and how to behave. For function mocks, the `onCall` function (generated for you) has the same parameter signature as the function itself. The return value of the `onCall` function is a type that (via its `returnResults` method) informs the mock what to return when invoked with the given parameters. For our `IsFavorite` function mock, we tell it to expect to be called with parameters `1`, `2` and then `3` but only `3` is our favorite number [like so](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L16-L18):
31+
To get a mock to perform specific behaviors, you have to tell it what to expect and how to behave. For function mocks, the `onCall` function (generated for you) has the same parameter signature as the function itself. The return value of the `onCall` function is a type that (via its `returnResults` method) informs the mock what to return when invoked with the given parameters. For our `IsFavorite` function mock, we tell it to expect to be called with parameters `1`, `2` and then `3` but only `3` is our favorite number [like so](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L17-L19):
3232
```go
3333
isFavMock.onCall(1).returnResults(false)
3434
isFavMock.onCall(2).returnResults(false)
3535
isFavMock.onCall(3).returnResults(true)
3636
```
3737

38-
Working with interface mocks is very similar to working with function mocks. For interface mocks, the generated `onCall` method returns the expectation recorder of the mocked interface (a full implementation of the interface for recording expectations). For our `Writer` mock example, we tell it to expect a call to `Write` with the [following call](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L20-L21):
38+
Working with interface mocks is very similar to working with function mocks. For interface mocks, the generated `onCall` method returns the expectation recorder of the mocked interface (a full implementation of the interface for recording expectations). For our `Writer` mock example, we tell it to expect a call to `Write` with the [following call](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L21-L22):
3939
```go
4040
writerMock.onCall().Write([]byte("3")).
4141
returnResults(1, nil)
@@ -65,7 +65,7 @@ isFavMock.onCall(7).
6565
```
6666

6767
### Passing the mock to production code
68-
Each mock gets a generated `mock` method. This function accesses the implementation of the interface or function invoked by production code. In [our example](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L23-L26), we have a type called `FavWriter` that needs an `IsFavorite` function and a `Writer`:
68+
Each mock gets a generated `mock` method. This function accesses the implementation of the interface or function invoked by production code. In [our example](https://github.com/myshkin5/moqueries/blob/master/demo/demo_test.go#L24-L27), we have a type called `FavWriter` that needs an `IsFavorite` function and a `Writer`:
6969
```go
7070
d := demo.FavWriter{
7171
IsFav: isFavMock.mock(),

0 commit comments

Comments
 (0)