coin_test.go 780 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package coin
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. coin "go-common/app/service/main/coin/model"
  7. )
  8. const (
  9. mid = 23675773
  10. aid = 1
  11. realIP = "127.0.0.1"
  12. )
  13. func TestCoin(t *testing.T) {
  14. s := New(nil)
  15. time.Sleep(1 * time.Second)
  16. // coin
  17. testAddCoins(t, s)
  18. testArchiveUserCoins(t, s)
  19. }
  20. func testAddCoins(t *testing.T, s *Service) {
  21. arg := coin.ArgAddCoin{Mid: mid, Aid: aid, Multiply: 1, RealIP: realIP}
  22. if err := s.AddCoins(context.TODO(), &arg); err != nil {
  23. t.Logf("call.AddCoins error(%v)", err)
  24. }
  25. }
  26. func testArchiveUserCoins(t *testing.T, s *Service) {
  27. arg := coin.ArgCoinInfo{Mid: mid, Aid: aid, RealIP: realIP}
  28. if res, err := s.ArchiveUserCoins(context.TODO(), &arg); err != nil && res != nil {
  29. t.Logf("call.ArchiveUserCoins error(%v)", err)
  30. }
  31. }