-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp_test.go
More file actions
36 lines (27 loc) · 712 Bytes
/
Copy pathapp_test.go
File metadata and controls
36 lines (27 loc) · 712 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
36
package helios
import (
"testing"
"github.com/stretchr/testify/assert"
)
type A struct {
DataX string
DataY string
}
func (a *A) TableName() string {
return "abc"
}
type B struct {
DataZ string
}
func TestRegisterModel(t *testing.T) {
App.BeforeTest()
assert.Equal(t, 0, len(App.models), "No model registered")
App.RegisterModel(A{})
assert.Equal(t, 1, len(App.models), "Only one models registered")
App.RegisterModel(B{})
assert.Equal(t, 2, len(App.models), "Two models registered")
App.Migrate()
assert.True(t, DB.HasTable("abc"), "Model A should be migrated with table name abc")
assert.True(t, DB.HasTable("bs"), "Model B should be migrated with default table name")
App.CloseDB()
}