Skip to content

Commit

Permalink
go-tarantool: bump to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
askalt committed Oct 2, 2023
1 parent 3e6fbfc commit 54412a3
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed
- bump `go-tarantool` dependency to `v2`.

## [0.1.0] - 2023-09-08

### Changed
Expand Down
16 changes: 8 additions & 8 deletions converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"time"

"github.com/google/uuid"
"github.com/tarantool/go-tarantool/datetime"
"github.com/tarantool/go-tarantool/decimal"
"github.com/tarantool/go-tarantool/v2/datetime"
"github.com/tarantool/go-tarantool/v2/decimal"
)

// Converter is a converter from S to T.
Expand All @@ -33,8 +33,8 @@ var (
_ Converter[string, any] = (*IdentityConverter[string])(nil)
_ Converter[string, any] = (*StringToIntervalConverter)(nil)

_ Converter[*datetime.Datetime, string] = (*DatetimeToStringConverter)(nil)
_ Converter[datetime.Interval, string] = (*IntervalToStringConverter)(nil)
_ Converter[datetime.Datetime, string] = (*DatetimeToStringConverter)(nil)
_ Converter[datetime.Interval, string] = (*IntervalToStringConverter)(nil)
)

// IdentityConverter is a converter from S to any, that doesn't change the input.
Expand Down Expand Up @@ -164,7 +164,7 @@ func MakeStringToDecimalConverter(ignoreChars, decSeparators string) StringToDec
func (conv StringToDecimalConverter) Convert(src string) (any, error) {
src = replaceCharacters(src, conv.ignoreChars, "")
src = replaceCharacters(src, conv.decSeparators, ".")
return decimal.NewDecimalFromString(src)
return decimal.MakeDecimalFromString(src)
}

// StringToUUIDConverter is a converter from string to UUID.
Expand Down Expand Up @@ -206,7 +206,7 @@ func (StringToDatetimeConverter) Convert(src string) (any, error) {
}
_, offset := tm.Zone()
tm = tm.In(time.FixedZone(datetime.NoTimezone, offset))
return datetime.NewDatetime(tm)
return datetime.MakeDatetime(tm)
}
loc, err := time.LoadLocation(tzName)
if err != nil {
Expand All @@ -216,7 +216,7 @@ func (StringToDatetimeConverter) Convert(src string) (any, error) {
if err != nil {
return nil, err
}
return datetime.NewDatetime(tm)
return datetime.MakeDatetime(tm)
}

// StringToMapConverter is a converter from string to map.
Expand Down Expand Up @@ -343,7 +343,7 @@ func MakeDatetimeToStringConverter() DatetimeToStringConverter {

// Convert is the implementation of Converter[*datetime.Datetime, string]
// for DatetimeToStringConverter.
func (DatetimeToStringConverter) Convert(datetime *datetime.Datetime) (string, error) {
func (DatetimeToStringConverter) Convert(datetime datetime.Datetime) (string, error) {
tm := datetime.ToTime()
zone := tm.Location().String()
if zone != "" {
Expand Down
26 changes: 13 additions & 13 deletions converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
dec "github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tarantool/go-tarantool/datetime"
"github.com/tarantool/go-tarantool/decimal"
"github.com/tarantool/go-tarantool/v2/datetime"
"github.com/tarantool/go-tarantool/v2/decimal"
"github.com/tarantool/go-tupleconv"
)

Expand All @@ -38,8 +38,8 @@ func HelperTestConverter[S any, T any](
}
}

func getDatetimeWithValidate(t *testing.T, tm time.Time) *datetime.Datetime {
dt, err := datetime.NewDatetime(tm)
func getDatetimeWithValidate(t *testing.T, tm time.Time) datetime.Datetime {
dt, err := datetime.MakeDatetime(tm)
require.NoError(t, err)
return dt
}
Expand Down Expand Up @@ -247,35 +247,35 @@ func TestConverters(t *testing.T) {
tupleconv.MakeStringToDecimalConverter(thSeparators, decSeparators): {
{
value: "0",
expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(0), 0)},
expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(0), 0)},
},
{
value: "1",
expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1), 0)},
expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1), 0)},
},
{
value: "-1",
expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(-1), 0)},
expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(-1), 0)},
},
{
value: "43904329",
expected: &decimal.Decimal{
expected: decimal.Decimal{
Decimal: dec.NewFromBigInt(big.NewInt(43904329), 0),
},
},
{
value: "-9223372036854775808",
expected: &decimal.Decimal{
expected: decimal.Decimal{
Decimal: dec.NewFromBigInt(big.NewInt(int64(-9223372036854775808)), 0),
},
},
{
value: "1.447e+44",
expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1447), 41)},
expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1447), 41)},
},
{
value: "1*5",
expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(15), -1)},
expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(15), -1)},
},

// Error.
Expand Down Expand Up @@ -320,7 +320,7 @@ func TestMakeDatetimeToStringConverter(t *testing.T) {
parisLoc)
time3 := time.Date(2020, 9, 14, 12, 12, 12, 0, time.UTC)

cases := []convCase[*datetime.Datetime, string]{
cases := []convCase[datetime.Datetime, string]{
{
value: getDatetimeWithValidate(t, time1),
expected: "2023-08-30T12:06:05.123456789+0400",
Expand All @@ -335,7 +335,7 @@ func TestMakeDatetimeToStringConverter(t *testing.T) {
},
}
converter := tupleconv.MakeDatetimeToStringConverter()
HelperTestConverter[*datetime.Datetime, string](t, converter, cases)
HelperTestConverter[datetime.Datetime, string](t, converter, cases)
}

func TestMakeIntervalToStringConverter(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package tupleconv_test
import (
"errors"
"fmt"
"github.com/tarantool/go-tarantool"
"github.com/tarantool/go-tarantool/datetime"
"github.com/tarantool/go-tarantool/test_helpers"
"github.com/tarantool/go-tarantool/v2"
"github.com/tarantool/go-tarantool/v2/datetime"
"github.com/tarantool/go-tarantool/v2/test_helpers"
"github.com/tarantool/go-tupleconv"
"strconv"
"strings"
"time"

_ "github.com/tarantool/go-tarantool/uuid"
_ "github.com/tarantool/go-tarantool/v2/uuid"
)

type filterIntConverter struct {
Expand Down Expand Up @@ -207,7 +207,7 @@ func makeTtEncoder() func(any) (string, error) {
return func(src any) (string, error) {
switch src := src.(type) {
case datetime.Datetime:
return datetimeConverter.Convert(&src)
return datetimeConverter.Convert(src)
default:
return fmt.Sprint(src), nil
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/google/uuid v1.3.0
github.com/shopspring/decimal v1.3.1
github.com/stretchr/testify v1.7.1
github.com/tarantool/go-tarantool v1.11.0
github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2
)

require (
Expand All @@ -15,7 +15,8 @@ require (
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 // indirect
github.com/tarantool/go-iproto v0.1.0 // indirect
github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tarantool/go-iproto v0.1.0 h1:zHN9AA8LDawT+JBD0/Nxgr/bIsWkkpDzpcMuaNPSIAQ=
github.com/tarantool/go-iproto v0.1.0/go.mod h1:LNCtdyZxojUed8SbOiYHoc3v9NvaZTB7p96hUySMlIo=
github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 h1:/AN3eUPsTlvF6W+Ng/8ZjnSU6o7L0H4Wb9GMks6RkzU=
github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195/go.mod h1:M7H4xYSbzqpW/ZRBMyH0eyqQBsnhAMfsYk5mv0yid7A=
github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a h1:eeElglRXJ3xWKkHmDbeXrQWlZyQ4t3Ca1YlZsrfdXFU=
github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a/go.mod h1:M7H4xYSbzqpW/ZRBMyH0eyqQBsnhAMfsYk5mv0yid7A=
github.com/tarantool/go-tarantool v1.11.0 h1:iLw8kYDQNFA3c3VHhBJJajXKUJPaz0StY/CdrutDn6s=
github.com/tarantool/go-tarantool v1.11.0/go.mod h1:QRiXv0jnxwgxHtr9ZmifSr/eRba76gTUBgp69pDMX1U=
github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2 h1:twlq30ASdD2pykY6GUht00Po//UaZ9f1UCHWWnlJlaQ=
github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2/go.mod h1:wxReV/1H1dOTV47NebCEEbjTiqzRdGnQwEomU9YcwDo=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
Expand Down
10 changes: 5 additions & 5 deletions tt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
dec "github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tarantool/go-tarantool/datetime"
"github.com/tarantool/go-tarantool/decimal"
"github.com/tarantool/go-tarantool/v2/datetime"
"github.com/tarantool/go-tarantool/v2/decimal"
"github.com/tarantool/go-tupleconv"
"math/big"
"testing"
Expand Down Expand Up @@ -328,19 +328,19 @@ func TestStringToTTConvFactory(t *testing.T) {
tupleconv.TypeDecimal: {
{
value: "12`13`144",
expected: &decimal.Decimal{
expected: decimal.Decimal{
Decimal: dec.NewFromBigInt(big.NewInt(1213144), 0),
},
},
{
value: "111`22e333",
expected: &decimal.Decimal{
expected: decimal.Decimal{
Decimal: dec.NewFromBigInt(big.NewInt(11122), 333),
},
},
{
value: "11,12",
expected: &decimal.Decimal{
expected: decimal.Decimal{
Decimal: dec.NewFromBigInt(big.NewInt(1112), -2),
},
},
Expand Down

0 comments on commit 54412a3

Please sign in to comment.