api_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package game
  2. import (
  3. "context"
  4. "go-common/app/interface/main/creative/model/game"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. gock "gopkg.in/h2non/gock.v1"
  8. )
  9. func TestGameList(t *testing.T) {
  10. var (
  11. c = context.TODO()
  12. keywordStr = "kw"
  13. ip = "127.0.0.1"
  14. err error
  15. data []*game.ListItem
  16. )
  17. convey.Convey("List", t, func(ctx convey.C) {
  18. defer gock.OffAll()
  19. httpMock("Do", d.gameListURL).Reply(-502)
  20. data, err = d.List(c, keywordStr, ip)
  21. ctx.Convey("List", func(ctx convey.C) {
  22. ctx.So(err, convey.ShouldNotBeNil)
  23. ctx.So(data, convey.ShouldBeNil)
  24. })
  25. })
  26. }
  27. func TestGameInfo(t *testing.T) {
  28. var (
  29. c = context.TODO()
  30. gameBaseID = int64(0)
  31. platForType = int(0)
  32. ip = "127.0.0.1"
  33. info *game.Info
  34. err error
  35. )
  36. convey.Convey("Info", t, func(ctx convey.C) {
  37. defer gock.OffAll()
  38. httpMock("Do", d.gameListURL).Reply(-502)
  39. info, err = d.Info(c, gameBaseID, platForType, ip)
  40. ctx.Convey("Info", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldNotBeNil)
  42. ctx.So(info, convey.ShouldBeNil)
  43. })
  44. })
  45. }