mirror of
https://github.com/wahyd4/go-mocket.git
synced 2026-08-09 04:46:54 +10:00
Update README
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
|
||||
[](https://godoc.org/github.com/Selvatico/go-mocket) [](https://travis-ci.org/Selvatico/go-mocket) [](https://goreportcard.com/report/github.com/Selvatico/go-mocket)
|
||||
|
||||
### Go-Mocket
|
||||
|
||||
Go-Mocket is library inspired by [DATA-DOG/go-sqlmock](https://github.com/DATA-DOG/go-sqlmock)
|
||||
As inspiration library it is implementation of [sql/driver](https://godoc.org/database/sql/driver) interface but at the same time follows different approaches and has only similar API.
|
||||
This library helps to mock any DB connection also with [jinzhu/gorm](https://github.com/jinzhu/gorm) and it was main goal to create it
|
||||
As inspiration library, it is the implementation of [sql/driver](https://godoc.org/database/sql/driver) interface but at the same time follows different approaches and has only a similar API.
|
||||
This library helps to mock any DB connection also with [jinzhu/gorm](https://github.com/jinzhu/gorm), and it was the main goal to create it
|
||||
|
||||
List of features in the library:
|
||||
|
||||
* Mock `INSERT`, `UPDATE`, `SELECT`, `DELETE`
|
||||
* Support of transactions
|
||||
* 2 API's to use - `chaining` and via specifying whole mock object
|
||||
* 2 API's to use - `chaining` and via specifying a whole mock object
|
||||
* Matching by prepared statements arguments
|
||||
* You will not require to change anything inside you code to start using this library
|
||||
* You don't require to change anything inside your code to start using this library
|
||||
* Ability to trigger exceptions
|
||||
* Attach callbacks to mocked response to add additional check or modify response
|
||||
* Attach callbacks to mocked response to add an additional check or modify a response
|
||||
|
||||
**NOTE** Please be aware that driver catches SQL without DB specifics. Generating of queries is done by *sql* package
|
||||
**NOTE**, Please be aware that driver catches SQL without DB specifics. Generating of queries is done by *SQL* package
|
||||
|
||||
#### Install
|
||||
|
||||
@@ -30,11 +29,11 @@ go get github.com/Selvatico/go-mocket
|
||||
There are two possible ways to use `mocket`:
|
||||
|
||||
* Chaining API
|
||||
* Specifying `FakeResponse` object with all fields manually. Could be useful for cases when mocks stored separately as list of FakeResponses.
|
||||
* Specifying `FakeResponse` object with all fields manually. Could be useful for cases when mocks stored separately as the list of FakeResponses.
|
||||
|
||||
##### Enabling driver
|
||||
|
||||
Somewhere in you code to setup a tests
|
||||
Somewhere in your code to set up a tests
|
||||
|
||||
```go
|
||||
import (
|
||||
@@ -54,7 +53,7 @@ func SetupTests() {
|
||||
}
|
||||
```
|
||||
|
||||
Now if use singleton instance of DB it will use everywhere mocked connection.
|
||||
Now if use singleton instance of DB, it uses everywhere mocked connection.
|
||||
|
||||
##### Chain usage
|
||||
|
||||
@@ -114,5 +113,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user