Moving PtrOf to package internal/ptr
This commit is contained in:
parent
99be328e9d
commit
c2703558d7
13 changed files with 148 additions and 136 deletions
|
|
@ -2,6 +2,7 @@ package postgres
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-jet/jet/v2/internal/utils/ptr"
|
||||
"github.com/volatiletech/null/v8"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -93,7 +94,7 @@ func TestScanToValidDestination(t *testing.T) {
|
|||
|
||||
err := oneInventoryQuery.Query(db, &dest)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, dest[0], testutils.PtrOf(int32(1)))
|
||||
require.Equal(t, dest[0], ptr.Of(int32(1)))
|
||||
})
|
||||
|
||||
t.Run("NULL to integer", func(t *testing.T) {
|
||||
|
|
@ -530,10 +531,10 @@ func TestScanToSlice(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, len(dest), 2)
|
||||
testutils.AssertDeepEqual(t, dest[0].Film, film1)
|
||||
testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{testutils.PtrOf(int32(1)), testutils.PtrOf(int32(2)), testutils.PtrOf(int32(3)), testutils.PtrOf(int32(4)),
|
||||
testutils.PtrOf(int32(5)), testutils.PtrOf(int32(6)), testutils.PtrOf(int32(7)), testutils.PtrOf(int32(8))})
|
||||
testutils.AssertDeepEqual(t, dest[0].IDs, []*int32{ptr.Of(int32(1)), ptr.Of(int32(2)), ptr.Of(int32(3)), ptr.Of(int32(4)),
|
||||
ptr.Of(int32(5)), ptr.Of(int32(6)), ptr.Of(int32(7)), ptr.Of(int32(8))})
|
||||
testutils.AssertDeepEqual(t, dest[1].Film, film2)
|
||||
testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{testutils.PtrOf(int32(9)), testutils.PtrOf(int32(10))})
|
||||
testutils.AssertDeepEqual(t, dest[1].IDs, []*int32{ptr.Of(int32(9)), ptr.Of(int32(10))})
|
||||
})
|
||||
|
||||
t.Run("complex struct 1", func(t *testing.T) {
|
||||
|
|
@ -1076,10 +1077,10 @@ VALUES (1234, 0, 'Joe', '', NULL, 1, TRUE, '2020-02-02 10:00:00Z', NULL, 1);
|
|||
var address256 = model.Address{
|
||||
AddressID: 256,
|
||||
Address: "1497 Yuzhou Drive",
|
||||
Address2: testutils.PtrOf(""),
|
||||
Address2: ptr.Of(""),
|
||||
District: "England",
|
||||
CityID: 312,
|
||||
PostalCode: testutils.PtrOf("3433"),
|
||||
PostalCode: ptr.Of("3433"),
|
||||
Phone: "246810237916",
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
|
||||
}
|
||||
|
|
@ -1087,10 +1088,10 @@ var address256 = model.Address{
|
|||
var addres517 = model.Address{
|
||||
AddressID: 517,
|
||||
Address: "548 Uruapan Street",
|
||||
Address2: testutils.PtrOf(""),
|
||||
Address2: ptr.Of(""),
|
||||
District: "Ontario",
|
||||
CityID: 312,
|
||||
PostalCode: testutils.PtrOf("35653"),
|
||||
PostalCode: ptr.Of("35653"),
|
||||
Phone: "879347453467",
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2006-02-15 09:45:30", 0),
|
||||
}
|
||||
|
|
@ -1100,12 +1101,12 @@ var customer256 = model.Customer{
|
|||
StoreID: 2,
|
||||
FirstName: "Mattie",
|
||||
LastName: "Hoffman",
|
||||
Email: testutils.PtrOf("mattie.hoffman@sakilacustomer.org"),
|
||||
Email: ptr.Of("mattie.hoffman@sakilacustomer.org"),
|
||||
AddressID: 256,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
|
||||
Active: testutils.PtrOf(int32(1)),
|
||||
Active: ptr.Of(int32(1)),
|
||||
}
|
||||
|
||||
var customer512 = model.Customer{
|
||||
|
|
@ -1113,12 +1114,12 @@ var customer512 = model.Customer{
|
|||
StoreID: 1,
|
||||
FirstName: "Cecil",
|
||||
LastName: "Vines",
|
||||
Email: testutils.PtrOf("cecil.vines@sakilacustomer.org"),
|
||||
Email: ptr.Of("cecil.vines@sakilacustomer.org"),
|
||||
AddressID: 517,
|
||||
Activebool: true,
|
||||
CreateDate: *testutils.TimestampWithoutTimeZone("2006-02-14 00:00:00", 0),
|
||||
LastUpdate: testutils.TimestampWithoutTimeZone("2013-05-26 14:49:45.738", 0),
|
||||
Active: testutils.PtrOf(int32(1)),
|
||||
Active: ptr.Of(int32(1)),
|
||||
}
|
||||
|
||||
var countryUk = model.Country{
|
||||
|
|
@ -1151,32 +1152,32 @@ var inventory2 = model.Inventory{
|
|||
var film1 = model.Film{
|
||||
FilmID: 1,
|
||||
Title: "Academy Dinosaur",
|
||||
Description: testutils.PtrOf("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
|
||||
ReleaseYear: testutils.PtrOf(int32(2006)),
|
||||
Description: ptr.Of("A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies"),
|
||||
ReleaseYear: ptr.Of(int32(2006)),
|
||||
LanguageID: 1,
|
||||
RentalDuration: 6,
|
||||
RentalRate: 0.99,
|
||||
Length: testutils.PtrOf(int16(86)),
|
||||
Length: ptr.Of(int16(86)),
|
||||
ReplacementCost: 20.99,
|
||||
Rating: &pgRating,
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
|
||||
SpecialFeatures: testutils.PtrOf("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
|
||||
SpecialFeatures: ptr.Of("{\"Deleted Scenes\",\"Behind the Scenes\"}"),
|
||||
Fulltext: "'academi':1 'battl':15 'canadian':20 'dinosaur':2 'drama':5 'epic':4 'feminist':8 'mad':11 'must':14 'rocki':21 'scientist':12 'teacher':17",
|
||||
}
|
||||
|
||||
var film2 = model.Film{
|
||||
FilmID: 2,
|
||||
Title: "Ace Goldfinger",
|
||||
Description: testutils.PtrOf("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: testutils.PtrOf(int32(2006)),
|
||||
Description: ptr.Of("A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China"),
|
||||
ReleaseYear: ptr.Of(int32(2006)),
|
||||
LanguageID: 1,
|
||||
RentalDuration: 3,
|
||||
RentalRate: 4.99,
|
||||
Length: testutils.PtrOf(int16(48)),
|
||||
Length: ptr.Of(int16(48)),
|
||||
ReplacementCost: 12.99,
|
||||
Rating: &gRating,
|
||||
LastUpdate: *testutils.TimestampWithoutTimeZone("2013-05-26 14:50:58.951", 3),
|
||||
SpecialFeatures: testutils.PtrOf(`{Trailers,"Deleted Scenes"}`),
|
||||
SpecialFeatures: ptr.Of(`{Trailers,"Deleted Scenes"}`),
|
||||
Fulltext: `'ace':1 'administr':9 'ancient':19 'astound':4 'car':17 'china':20 'databas':8 'epistl':5 'explor':12 'find':15 'goldfing':2 'must':14`,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue