common_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package gorm
  2. import (
  3. "testing"
  4. "github.com/jinzhu/gorm"
  5. "github.com/smartystreets/goconvey/convey"
  6. "go-common/app/admin/main/aegis/model/net"
  7. )
  8. func TestDaoAvailable(t *testing.T) {
  9. var (
  10. db = &gorm.DB{}
  11. )
  12. convey.Convey("Available", t, func(ctx convey.C) {
  13. p1 := Available(db)
  14. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  15. ctx.So(p1, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoDisable(t *testing.T) {
  20. var (
  21. db = &gorm.DB{}
  22. )
  23. convey.Convey("Disable", t, func(ctx convey.C) {
  24. p1 := Disable(db)
  25. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  26. ctx.So(p1, convey.ShouldNotBeNil)
  27. })
  28. })
  29. }
  30. func TestDaostatePager(t *testing.T) {
  31. var (
  32. s1 = ""
  33. )
  34. convey.Convey("state", t, func(ctx convey.C) {
  35. p1 := state(s1)
  36. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  37. ctx.So(p1, convey.ShouldNotBeNil)
  38. })
  39. })
  40. }
  41. func TestDao_ColumnMapString(t *testing.T) {
  42. var (
  43. table = net.TableFlow
  44. column = "ch_name"
  45. ids = []int64{1, 2, 3}
  46. )
  47. convey.Convey("ColumnMapString", t, func(ctx convey.C) {
  48. result, err := d.ColumnMapString(cntx, table, column, ids, "")
  49. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. })
  52. t.Logf("result(%+v)", result)
  53. })
  54. }