Skip to content

Commit

Permalink
Update main_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
IrineSistiana authored Aug 23, 2023
1 parent 3f14b65 commit 49617f4
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
package main

import (
"log"
"os"
"testing"
)

// GORM_REPO: https://github.com/go-gorm/gorm.git
// GORM_BRANCH: master
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver

func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}
"github.com/stretchr/testify/require"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

DB.Create(&user)
type M struct {
ID uint64 `gorm:"primarykey"`
I string `gorm:"uniqueIndex:idx_name"`
I2 string `gorm:"uniqueIndex:idx_name"`
}

var result User
if err := DB.First(&result, user.ID).Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}
func Test(t *testing.T) {
r := require.New(t)
db, err := gorm.Open(sqlite.Open("test.sqlite3?_journal=WAL"), &gorm.Config{
Logger: logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags),
logger.Config{
LogLevel: logger.Info,
},
),
})
r.NoError(err)
db.AutoMigrate(&M{})
}

0 comments on commit 49617f4

Please sign in to comment.