platform_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/vip/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoPlatformSuit(t *testing.T) {
  9. convey.Convey("PlatformSuit", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. arg = &model.ConfPlatform{
  13. ID: 1,
  14. PlatformName: "android-ut",
  15. Platform: "android",
  16. Device: "phone",
  17. MobiApp: "android",
  18. PanelType: "normal",
  19. Operator: "test1",
  20. }
  21. )
  22. ctx.Convey("clean data before", func(ctx convey.C) {
  23. d.vip.Table(_vipConfPlatform).Where("platform_name=?", "android-ut").Delete(model.ConfPlatform{})
  24. })
  25. ctx.Convey("PlatformSave", func(ctx convey.C) {
  26. eff, err := d.PlatformSave(c, arg)
  27. ctx.So(err, convey.ShouldBeNil)
  28. ctx.So(eff, convey.ShouldNotBeNil)
  29. })
  30. ctx.Convey("PlatformByID", func(ctx convey.C) {
  31. re, err := d.PlatformByID(c, arg.ID)
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(re, convey.ShouldNotBeNil)
  34. })
  35. ctx.Convey("PlatformAll", func(ctx convey.C) {
  36. res, err := d.PlatformAll(c, "desc")
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(res, convey.ShouldNotBeNil)
  39. })
  40. ctx.Convey("PlatformDel", func(ctx convey.C) {
  41. eff, err := d.PlatformDel(c, arg.ID, arg.Operator)
  42. ctx.So(err, convey.ShouldBeNil)
  43. ctx.So(eff, convey.ShouldBeGreaterThanOrEqualTo, 0)
  44. })
  45. ctx.Convey("clean data", func(ctx convey.C) {
  46. d.vip.Table(_vipConfPlatform).Where("platform_name=?", "android-ut").Delete(model.ConfPlatform{})
  47. })
  48. })
  49. }
  50. func TestDaoPlatformTypes(t *testing.T) {
  51. convey.Convey("PlatformTypes", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. )
  55. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  56. res, err := d.PlatformTypes(c)
  57. ctx.So(err, convey.ShouldBeNil)
  58. ctx.So(res, convey.ShouldNotBeNil)
  59. })
  60. })
  61. }