From b3dc9e3ffb68899ec559576224bc8cc4ac6c8b14 Mon Sep 17 00:00:00 2001 From: rahul yadav Date: Tue, 31 Oct 2023 11:19:40 +0530 Subject: [PATCH] fix test --- samples/interleave/sample.go | 6 +++--- samples/samples_test.go | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/samples/interleave/sample.go b/samples/interleave/sample.go index 90130d4..5d912d3 100644 --- a/samples/interleave/sample.go +++ b/samples/interleave/sample.go @@ -390,7 +390,7 @@ func PrintAlbumsReleaseBefore1900(w io.Writer, db *gorm.DB) error { var albums []*Album if err := db.Where( "release_date < ?", - civil.DateOf(time.Date(1900, time.January, 1, 0, 0, 0, 0, time.UTC)), + spanner.NullDate{Valid: true, Date: civil.DateOf(time.Date(1900, time.January, 1, 0, 0, 0, 0, time.UTC))}, ).Order("release_date asc").Find(&albums).Error; err != nil { return fmt.Errorf("failed to load albums: %w", err) } @@ -633,9 +633,9 @@ func randInt(min, max int) int { func randDate() spanner.NullDate { if rand.Int()%2 == 0 { - return spanner.NullDate{Date: civil.DateOf(time.Date(randInt(1850, 1899), time.Month(randInt(1, 12)), randInt(1, 28), 0, 0, 0, 0, time.UTC))} + return spanner.NullDate{Valid: true, Date: civil.DateOf(time.Date(randInt(1850, 1899), time.Month(randInt(1, 12)), randInt(1, 28), 0, 0, 0, 0, time.UTC))} } - return spanner.NullDate{Date: civil.DateOf(time.Date(randInt(1850, 2010), time.Month(randInt(1, 12)), randInt(1, 28), 0, 0, 0, 0, time.UTC))} + return spanner.NullDate{Valid: true, Date: civil.DateOf(time.Date(randInt(1850, 2010), time.Month(randInt(1, 12)), randInt(1, 28), 0, 0, 0, 0, time.UTC))} } func randBytes(length int) []byte { diff --git a/samples/samples_test.go b/samples/samples_test.go index 561721e..5ea06dc 100644 --- a/samples/samples_test.go +++ b/samples/samples_test.go @@ -11,8 +11,7 @@ import ( "github.com/stretchr/testify/require" "gorm.io/gorm" - "gorm.io/gorm/logger" - + spannergorm "github.com/googleapis/go-gorm-spanner" "github.com/googleapis/go-gorm-spanner/samples/interleave" "github.com/googleapis/go-gorm-spanner/testutil" @@ -33,7 +32,7 @@ func TestIntegration_Sample(t *testing.T) { db, err := gorm.Open(spannergorm.New(spannergorm.Config{ DriverName: "spanner", DSN: dsn, - }), &gorm.Config{PrepareStmt: true, IgnoreRelationshipsWhenMigrating: true, Logger: logger.Default.LogMode(logger.Error)}) + }), &gorm.Config{PrepareStmt: true, IgnoreRelationshipsWhenMigrating: true}) require.NoError(t, err) require.NoError(t, samples.CreateInterleavedTablesIfNotExist(os.Stdout, db)) require.NoError(t, db.AutoMigrate(&samples.Venue{}, &samples.Concert{}))