Skip to content

Commit 8b4b22b

Browse files
committed
doc(readme): upgrade
1 parent 87624cc commit 8b4b22b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/hedon954/go-mysql-mocker?sort=semver)](https://github.com/hedon954/go-mysql-mocker/releases)
77
[![Go Reference](https://pkg.go.dev/badge/github.com/hedon954/go-mysql-mocker.svg)](https://pkg.go.dev/github.com/hedon954/go-mysql-mocker)
88

9-
109
`go-mysql-mocker(gmm)` was created to provide developers with a reliable and straightforward tool for mocking MySQL interactions in Go applications, particularly for automated testing environments. By simulating a MySQL server, `go-mysql-mocker` allows developers to conduct unit tests without the overhead of setting up a real database, thus speeding up test cycles and reducing external dependencies. This is especially useful in continuous integration (CI) environments where test reliability and speed are paramount.
1110

1211
![architecture](./design/img/architecture.png)
@@ -24,7 +23,8 @@
2423

2524
## Requirements
2625

27-
- Go 1.20 (or later versions)
26+
- Go 1.20 (<=v1.0.6)
27+
- Go 1.24 (>=v1.0.7)
2828

2929
## Installation
3030

@@ -41,10 +41,10 @@ go get -u github.com/hedon954/go-mysql-mocker
4141
- `SQLFiles(files)`: Reads SQL statements from specified files and executes them to generate test data. This method is useful for initializing the database with a larger set of pre-defined SQL operations.
4242
- `Build()`: Initializes and starts the MySQL server with all specified configurations and initializes the data. This method must be called to execute the configurations set up by the preceding methods.
4343

44-
4544
## Quick Start
4645

4746
### prepare a data model and implement `TableName()` interface
47+
4848
```go
4949
type UserState struct {
5050
UID string `gorm:"primaryKey;column:uid"`
@@ -57,6 +57,7 @@ func (u UserState) TableName() string {
5757
```
5858

5959
### write a business logic
60+
6061
```go
6162
func ChangeUserStateToMatch(db *sql.DB, uid string) (int64, error) {
6263
res, err := db.Exec("UPDATE user_state SET state = 'match' WHERE uid = ?", uid)
@@ -68,6 +69,7 @@ func ChangeUserStateToMatch(db *sql.DB, uid string) (int64, error) {
6869
```
6970

7071
### use `gmm` to test it
72+
7173
```go
7274
func TestChangeUserStateToMatch(t *testing.T) {
7375
t.Run("no data should have no affect row", func(t *testing.T) {

0 commit comments

Comments
 (0)