forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: update all
Update
and Upsert
requests
`Op` struct made private. Change all `Upsert` and `Update` requests to accept `*tarantool.Operations` as `ops` parameters instead of `interface{}`. Closes #348
- Loading branch information
Showing
15 changed files
with
149 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package tarantool_test | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/vmihailenco/msgpack/v5" | ||
|
||
"github.com/tarantool/go-tarantool/v2" | ||
) | ||
|
||
func TestOperations_EncodeMsgpack(t *testing.T) { | ||
ops := tarantool.NewOperations(). | ||
Add(1, 2). | ||
Subtract(1, 2). | ||
BitwiseAnd(1, 2). | ||
BitwiseOr(1, 2). | ||
BitwiseXor(1, 2). | ||
Splice(1, 2, 3, "a"). | ||
Insert(1, 2). | ||
Delete(1, 2). | ||
Assign(1, 2) | ||
refOps := []interface{}{ | ||
[]interface{}{"+", 1, 2}, | ||
[]interface{}{"-", 1, 2}, | ||
[]interface{}{"&", 1, 2}, | ||
[]interface{}{"|", 1, 2}, | ||
[]interface{}{"^", 1, 2}, | ||
[]interface{}{":", 1, 2, 3, "a"}, | ||
[]interface{}{"!", 1, 2}, | ||
[]interface{}{"#", 1, 2}, | ||
[]interface{}{"=", 1, 2}, | ||
} | ||
|
||
var refBuf bytes.Buffer | ||
encRef := msgpack.NewEncoder(&refBuf) | ||
if err := encRef.Encode(refOps); err != nil { | ||
t.Errorf("error while encoding: %v", err.Error()) | ||
} | ||
|
||
var buf bytes.Buffer | ||
enc := msgpack.NewEncoder(&buf) | ||
|
||
if err := enc.Encode(ops); err != nil { | ||
t.Errorf("error while encoding: %v", err.Error()) | ||
} | ||
if !bytes.Equal(refBuf.Bytes(), buf.Bytes()) { | ||
t.Errorf("encode response is wrong:\n expected %v\n got: %v", | ||
refBuf, buf.Bytes()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.