coupon_service_test.go 845 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package service
  2. import (
  3. "fmt"
  4. "testing"
  5. "xiaoniaokuaiyan.com/xiaoniao/dal"
  6. "xiaoniaokuaiyan.com/xiaoniao/entity"
  7. )
  8. func TestAddCoupon(t *testing.T) {
  9. coupon := &entity.DiscountTicket{
  10. TypeId: 1,
  11. Mobile: "18310412106",
  12. Value: 100.0,
  13. Deadline: "2016-05-16",
  14. }
  15. srv := &CouponService{
  16. ICoupon: dal.DefaultCouponDal,
  17. }
  18. ret, err := srv.AddCoupon(coupon)
  19. if err != nil {
  20. t.Fatal(err)
  21. }
  22. fmt.Println(ret)
  23. }
  24. func TestListCoupon(t *testing.T) {
  25. srv := &CouponService{
  26. ICoupon: dal.DefaultCouponDal,
  27. }
  28. ret, err := srv.ListCoupon("13810833508", 1, 1, 10)
  29. if err != nil {
  30. t.Fatal(err)
  31. }
  32. fmt.Println(ret)
  33. }
  34. func TestExchangeCode(t *testing.T) {
  35. srv := &CouponService{
  36. ICoupon: dal.DefaultCouponDal,
  37. }
  38. ret, err := srv.Exchange("xxxxx", 4, "18310412106")
  39. if err != nil {
  40. t.Fatal(err)
  41. }
  42. fmt.Println(ret)
  43. }