Skip to content

tests: added test for Body() methods of requests using golden files #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Implemented box.session.su request and sugar interface only for current session granting (#426).
- Defined `ErrConcurrentSchemaUpdate` constant for "concurrent schema update" error.
Now you can check this error with `errors.Is(err, tarantool.ErrConcurrentSchemaUpdate)`.
- Implemented support for `IPROTO_IS_SYNC` flag in stream transactions,
added `IsSync(bool)` method for `BeginRequest`/`CommitRequest` (#447).

### Changed

Expand Down
84 changes: 84 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,90 @@ func ExampleBeginRequest_TxnIsolation() {
fmt.Printf("Select after Rollback: response is %#v\n", data)
}

func ExampleBeginRequest_IsSync() {
conn := exampleConnect(dialer, opts)
defer conn.Close()

// Tarantool supports IS_SYNC flag for BeginRequest since version 3.1.0.
isLess, err := test_helpers.IsTarantoolVersionLess(3, 1, 0)
if err != nil || isLess {
return
}

stream, err := conn.NewStream()
if err != nil {
fmt.Printf("error getting the stream: %s\n", err)
return
}

// Begin transaction with synchronous mode.
req := tarantool.NewBeginRequest().IsSync(true)
resp, err := stream.Do(req).GetResponse()
switch {
case err != nil:
fmt.Printf("error getting the response: %s\n", err)
case resp.Header().Error != tarantool.ErrorNo:
fmt.Printf("response error code: %s\n", resp.Header().Error)
default:
fmt.Println("Success.")
}
}

func ExampleCommitRequest_IsSync() {
conn := exampleConnect(dialer, opts)
defer conn.Close()

// Tarantool supports IS_SYNC flag for CommitRequest since version 3.1.0.
isLess, err := test_helpers.IsTarantoolVersionLess(3, 1, 0)
if err != nil || isLess {
return
}

var req tarantool.Request

stream, err := conn.NewStream()
if err != nil {
fmt.Printf("error getting the stream: %s\n", err)
return
}

// Begin transaction.
req = tarantool.NewBeginRequest()
resp, err := stream.Do(req).GetResponse()
switch {
case err != nil:
fmt.Printf("error getting the response: %s\n", err)
return
case resp.Header().Error != tarantool.ErrorNo:
fmt.Printf("response error code: %s\n", resp.Header().Error)
return
}

// Insert in stream.
req = tarantool.NewReplaceRequest("test").Tuple([]interface{}{1, "test"})
resp, err = stream.Do(req).GetResponse()
switch {
case err != nil:
fmt.Printf("error getting the response: %s\n", err)
return
case resp.Header().Error != tarantool.ErrorNo:
fmt.Printf("response error code: %s\n", resp.Header().Error)
return
}

// Commit transaction in sync mode.
req = tarantool.NewCommitRequest().IsSync(true)
resp, err = stream.Do(req).GetResponse()
switch {
case err != nil:
fmt.Printf("error getting the response: %s\n", err)
case resp.Header().Error != tarantool.ErrorNo:
fmt.Printf("response error code: %s\n", resp.Header().Error)
default:
fmt.Println("Success.")
}
}

func ExampleErrorNo() {
conn := exampleConnect(dialer, opts)
defer conn.Close()
Expand Down
158 changes: 0 additions & 158 deletions export_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion future_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (req *futureMockRequest) Async() bool {
return false
}

func (req *futureMockRequest) Body(resolver SchemaResolver, enc *msgpack.Encoder) error {
func (req *futureMockRequest) Body(_ SchemaResolver, _ *msgpack.Encoder) error {
return nil
}

Expand Down
Loading
Loading