content_ext_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. bm "go-common/library/net/http/blademaster"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestServiceBmHTTPErrorWithMsg(t *testing.T) {
  8. convey.Convey("BmHTTPErrorWithMsg", t, func(ctx convey.C) {
  9. var (
  10. c = &bm.Context{}
  11. err error
  12. msg = ""
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. BmHTTPErrorWithMsg(c, err, msg)
  16. ctx.Convey("No return values", func(ctx convey.C) {
  17. })
  18. })
  19. })
  20. }
  21. func TestServiceBmGetStringOrDefault(t *testing.T) {
  22. convey.Convey("BmGetStringOrDefault", t, func(ctx convey.C) {
  23. var (
  24. c = &bm.Context{}
  25. key = ""
  26. defaul = ""
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. value, exist := BmGetStringOrDefault(c, key, defaul)
  30. ctx.Convey("Then value,exist should not be nil.", func(ctx convey.C) {
  31. ctx.So(exist, convey.ShouldNotBeNil)
  32. ctx.So(value, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestServiceBmGetInt64OrDefault(t *testing.T) {
  38. convey.Convey("BmGetInt64OrDefault", t, func(ctx convey.C) {
  39. var (
  40. c = &bm.Context{}
  41. key = ""
  42. defaul = int64(0)
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. value, exist := BmGetInt64OrDefault(c, key, defaul)
  46. ctx.Convey("Then value,exist should not be nil.", func(ctx convey.C) {
  47. ctx.So(exist, convey.ShouldNotBeNil)
  48. ctx.So(value, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }