client_test.go 815 B

123456789101112131415161718192021222324252627282930313233343536
  1. package v1
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/library/ecode"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. var client ShareClient
  9. func init() {
  10. var err error
  11. client, err = NewClient(nil)
  12. if err != nil {
  13. panic(err)
  14. }
  15. }
  16. func TestAddShare(t *testing.T) {
  17. convey.Convey("TestAddShare", t, func(ctx convey.C) {
  18. var c = context.Background()
  19. ctx.Convey("When everything is correct", func(ctx convey.C) {
  20. reply, err := client.AddShare(c, &AddShareRequest{Oid: 22, Mid: 33, Type: 3})
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.Printf("%+v\n", reply.Shares)
  23. })
  24. ctx.Convey("When error", func(ctx convey.C) {
  25. reply, err := client.AddShare(c, &AddShareRequest{Oid: 22, Mid: 33, Type: 3})
  26. ctx.So(err, convey.ShouldEqual, ecode.ShareAlreadyAdd)
  27. ctx.So(reply, convey.ShouldBeNil)
  28. })
  29. })
  30. }