Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"testing"
)

Expand All @@ -8,7 +9,7 @@
// GORM_BRANCH: master
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver

func TestGORM(t *testing.T) {

Check failure on line 12 in main_test.go

View workflow job for this annotation

GitHub Actions / sqlite (1.24, ubuntu-latest)

other declaration of TestGORM
user := User{Name: "jinzhu"}

DB.Create(&user)
Expand All @@ -18,3 +19,20 @@
t.Errorf("Failed, got error: %v", err)
}
}

func TestGORM(t *testing.T) {

Check failure on line 23 in main_test.go

View workflow job for this annotation

GitHub Actions / sqlite (1.24, ubuntu-latest)

TestGORM redeclared in this block
user := User{Name: "jinzhu", IsDeleted: false}
DB = DB.Debug()

DB.Create(&user)

var user1 User
basicCondition := map[string]string{
fmt.Sprintf("%s.is_deleted", "users"): "false",
}
err := DB.Table("users").Where(basicCondition).Find(&user1)
if err != nil {
t.Errorf("Failed, got error: %v", err)
}
fmt.Printf("User: %v\n", user)
}
1 change: 1 addition & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type User struct {
Languages []Language `gorm:"many2many:UserSpeak"`
Friends []*User `gorm:"many2many:user_friends"`
Active bool
IsDeleted bool
}

type Account struct {
Expand Down
Loading