callback_test.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "testing"
  6. "go-common/app/admin/main/workflow/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoAllCallbacks(t *testing.T) {
  10. convey.Convey("AllCallbacks", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. cbs, err := d.AllCallbacks(c)
  16. ctx.Convey("Then err should be nil.cbs should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(cbs, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoSendCallback(t *testing.T) {
  24. convey.Convey("SendCallback", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. cb = &model.Callback{
  28. URL: "http://uat-manager.bilibili.co/x/admin/reply/internal/callback/del",
  29. }
  30. payload = &model.Payload{}
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. err := d.SendCallback(c, cb, payload)
  34. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaosign(t *testing.T) {
  41. convey.Convey("sign", t, func(ctx convey.C) {
  42. var (
  43. params url.Values
  44. appkey = ""
  45. secret = ""
  46. lower bool
  47. )
  48. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  49. hexdigest := sign(params, appkey, secret, lower)
  50. ctx.Convey("Then hexdigest should not be nil.", func(ctx convey.C) {
  51. ctx.So(hexdigest, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }