coin_test.go 696 B

1234567891011121314151617181920212223242526
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. coin "go-common/app/service/main/coin/api/gorpc"
  6. coinMdl "go-common/app/service/main/coin/model"
  7. "github.com/golang/mock/gomock"
  8. . "github.com/smartystreets/goconvey/convey"
  9. )
  10. func Test_Coin(t *testing.T) {
  11. mid := int64(1)
  12. aid := int64(1)
  13. Convey("get data", t, WithMock(t, func(mockCtrl *gomock.Controller) {
  14. mock := coin.NewMockRPC(mockCtrl)
  15. s.coinRPC = mock
  16. arg := &coinMdl.ArgCoinInfo{Mid: mid, Aid: aid, AvType: 2}
  17. mock.EXPECT().ArchiveUserCoins(gomock.Any(), arg).Return(&coinMdl.ArchiveUserCoins{Multiply: 10}, nil)
  18. res, err := s.Coin(context.TODO(), mid, aid, "")
  19. So(err, ShouldBeNil)
  20. So(res, ShouldEqual, 10)
  21. }))
  22. }