token_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package gorm
  2. import (
  3. "go-common/app/admin/main/aegis/model/net"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoTokens(t *testing.T) {
  8. var (
  9. ids = []int64{}
  10. )
  11. convey.Convey("Tokens", t, func(ctx convey.C) {
  12. no, err := d.Tokens(cntx, ids)
  13. ctx.Convey("Then err should be nil.no should not be nil.", func(ctx convey.C) {
  14. ctx.So(err, convey.ShouldBeNil)
  15. ctx.So(no, convey.ShouldNotBeNil)
  16. })
  17. })
  18. }
  19. func TestDaoTokenList(t *testing.T) {
  20. convey.Convey("TokenList", t, func(ctx convey.C) {
  21. result, err := d.TokenList(cntx, []int64{1}, []int64{}, "1", true)
  22. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  23. ctx.So(err, convey.ShouldBeNil)
  24. ctx.So(result, convey.ShouldNotBeNil)
  25. })
  26. })
  27. }
  28. func TestDaoTokenByID(t *testing.T) {
  29. convey.Convey("TokenByID", t, func(ctx convey.C) {
  30. d.TokenByID(cntx, 1)
  31. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  32. })
  33. })
  34. }
  35. func TestDaoTokenListWithPager(t *testing.T) {
  36. var (
  37. pm = &net.ListTokenParam{}
  38. )
  39. convey.Convey("TokenListWithPager", t, func(ctx convey.C) {
  40. result, err := d.TokenListWithPager(cntx, pm)
  41. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. ctx.So(result, convey.ShouldNotBeNil)
  44. })
  45. })
  46. }
  47. func TestDaoTokenByUnique(t *testing.T) {
  48. convey.Convey("TokenByUnique", t, func(ctx convey.C) {
  49. _, err := d.TokenByUnique(cntx, 0, "", 0, "")
  50. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. })
  53. })
  54. }
  55. func TestDaoTokenBinds(t *testing.T) {
  56. convey.Convey("TokenBinds", t, func(ctx convey.C) {
  57. result, err := d.TokenBinds(cntx, []int64{})
  58. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  59. ctx.So(err, convey.ShouldBeNil)
  60. ctx.So(result, convey.ShouldNotBeNil)
  61. })
  62. })
  63. }
  64. func TestDaoTokenBindByElement(t *testing.T) {
  65. convey.Convey("TokenBindByElement", t, func(ctx convey.C) {
  66. result, err := d.TokenBindByElement(cntx, []int64{}, []int8{}, true)
  67. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldBeNil)
  69. ctx.So(result, convey.ShouldNotBeNil)
  70. })
  71. })
  72. }