Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Oct 31, 2023
1 parent 73ba752 commit b3dc9e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions samples/interleave/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions samples/samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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{}))
Expand Down

0 comments on commit b3dc9e3

Please sign in to comment.