ut_dash_test.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/apm/model/ut"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestServiceDashCurveGraph(t *testing.T) {
  9. convey.Convey("ProjectCurveGraph", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. req = &ut.PCurveReq{
  13. StartTime: 1536508800,
  14. EndTime: 1541779200,
  15. }
  16. username = "fengshanshan"
  17. )
  18. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  19. res, err := svr.DashCurveGraph(c, username, req)
  20. for _, r := range res {
  21. t.Logf("res:%+v", r)
  22. }
  23. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  24. ctx.So(err, convey.ShouldBeNil)
  25. ctx.So(res, convey.ShouldNotBeNil)
  26. })
  27. })
  28. })
  29. }
  30. func TestServiceDashGraphDetail(t *testing.T) {
  31. convey.Convey("ProjectGraphDetail", t, func(ctx convey.C) {
  32. var (
  33. c = context.Background()
  34. username = "haoguanwei"
  35. req = &ut.PCurveReq{
  36. StartTime: 1536508800,
  37. EndTime: 1541779200,
  38. Path: "go-common/app/admin/main/apm",
  39. }
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. res, err := svr.DashGraphDetail(c, username, req)
  43. for _, r := range res {
  44. t.Logf("res:%+v", r)
  45. }
  46. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. ctx.So(res, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestServiceDashGraphDetailSingle(t *testing.T) {
  54. convey.Convey("ProjectGraphDetailSingle", t, func(ctx convey.C) {
  55. var (
  56. c = context.Background()
  57. username = "haoguanwei"
  58. req = &ut.PCurveReq{
  59. User: "fengshanshan",
  60. StartTime: 1536508800,
  61. EndTime: 1541779200,
  62. }
  63. )
  64. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  65. res, err := svr.DashGraphDetailSingle(c, username, req)
  66. for _, r := range res {
  67. t.Logf("res:%+v\n", r)
  68. }
  69. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  70. ctx.So(err, convey.ShouldBeNil)
  71. ctx.So(res, convey.ShouldNotBeNil)
  72. })
  73. })
  74. })
  75. }
  76. func TestServiceDashPkgs(t *testing.T) {
  77. convey.Convey("DashboardPkgs", t, func(ctx convey.C) {
  78. var (
  79. c = context.Background()
  80. path = "go-common/app/"
  81. username = "zhaobingqing"
  82. )
  83. ctx.Convey("When path is none", func(ctx convey.C) {
  84. val, err := svr.DashPkgsTree(c, path, username)
  85. ctx.Convey("Error should be nil, pkgs should not be nil", func(ctx convey.C) {
  86. ctx.So(err, convey.ShouldBeNil)
  87. ctx.So(val, convey.ShouldNotBeNil)
  88. t.Logf("the val are %+v", val)
  89. })
  90. })
  91. // ctx.Convey("When path is not none", func(ctx convey.C) {
  92. // path = "go-common/app/service/main/block"
  93. // val, err := svr.GetPersonalPkgs(c, path, username)
  94. // ctx.Convey("Error should be nil, pkgs should not be nil", func(ctx convey.C) {
  95. // ctx.So(err, convey.ShouldBeNil)
  96. // ctx.So(val, convey.ShouldNotBeNil)
  97. // t.Logf("the val are %+v", val)
  98. // })
  99. // })
  100. })
  101. }
  102. func TestServiceAppsCache(t *testing.T) {
  103. convey.Convey("AppsCache", t, func(ctx convey.C) {
  104. var (
  105. c = context.Background()
  106. )
  107. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  108. err := svr.AppsCache(c)
  109. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldBeNil)
  111. })
  112. })
  113. })
  114. }