Vestmore_GO/test/gorm_test.go

37 lines
986 B
Go
Raw Permalink Normal View History

2024-04-10 09:30:12 +00:00
package vertmore_test
import (
"log"
"testing"
"github.com/iapologizewhenimwrong/Vestmore_GO/model"
"github.com/iapologizewhenimwrong/Vestmore_GO/utils/basic"
)
func TestCaseInsert(t *testing.T) {
2024-04-16 10:00:05 +00:00
c, err := model.Models.KillaraCustomerModel.GetCustomer(nil, 1)
2024-04-10 09:30:12 +00:00
if err != nil {
panic(err)
}
log.Printf("%#v", c)
c.CustomerId = nil
c.Email = basic.StringPtr("474420502@qq.com")
2024-04-16 10:00:05 +00:00
model.Models.KillaraCustomerModel.InsertCustomer(nil, c)
2024-04-10 09:30:12 +00:00
}
func TestUpdate(t *testing.T) {
2024-04-16 10:00:05 +00:00
c, err := model.Models.KillaraCustomerModel.GetCustomer(nil, 6)
2024-04-10 09:30:12 +00:00
if err != nil {
panic(err)
}
uc := &model.KillaraCustomer{}
uc.CustomerId = c.CustomerId
uc.Email = basic.StringPtr("474420502@gmail.com")
2024-04-16 10:00:05 +00:00
log.Println(model.Models.KillaraCustomerModel.UpdateCustomer(nil, uc))
2024-04-10 09:30:12 +00:00
}
func TestExist(t *testing.T) {
2024-04-16 10:00:05 +00:00
log.Println(model.Models.KillaraCustomerModel.CheckEmailExists(nil, "474420502@gmail.com"))
log.Println(model.Models.KillaraCustomerModel.CheckEmailExists(nil, "474420502@qq.com"))
2024-04-10 09:30:12 +00:00
}