forked from go-gorm/playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
35 lines (26 loc) · 804 Bytes
/
main_test.go
File metadata and controls
35 lines (26 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"testing"
"gorm.io/playground/models"
)
// GORM_REPO: https://github.com/go-gorm/gorm.git
// GORM_BRANCH: master
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver
func TestGORM(t *testing.T) {
user := models.User{Name: "jinzhu"}
DB.Create(&user)
var result models.User
if err := DB.First(&result, user.ID).Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}
}
// func TestGORMGen(t *testing.T) {
// user := models.User{Name: "jinzhu2"}
// ctx := context.Background()
// gorm.G[models.User](DB).Create(ctx, &user)
// if u, err := gorm.G[models.User](DB).Where(g.User.ID.Eq(user.ID)).First(ctx); err != nil {
// t.Errorf("Failed, got error: %v", err)
// } else if u.Name != user.Name {
// t.Errorf("Failed, got user name: %v", u.Name)
// }
// }