作者 陈志颖

chore:使用https

@@ -4,8 +4,8 @@ import "os" @@ -4,8 +4,8 @@ import "os"
4 4
5 const SERVICE_NAME = "mmm-worth" 5 const SERVICE_NAME = "mmm-worth"
6 6
7 -var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"  
8 -var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" 7 +var ABILITY_SERVICE_HOST = "://suplus-worth-app-gateway-dev.fjmaimaimai.com"
  8 +var MMM_OPEN_API_SERVICE_HOST = "https://mmm-open-api-dev.fjmaimaimai.com"
9 9
10 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
11 var LOG_File = "logs/app.log" 11 var LOG_File = "logs/app.log"
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/25
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_list
1 package exchange_list 1 package exchange_list
  2 +
  3 +import (
  4 + "net/http"
  5 + "os"
  6 + "strconv"
  7 + "time"
  8 +
  9 + "github.com/gavv/httpexpect"
  10 + "github.com/go-pg/pg"
  11 + . "github.com/onsi/ginkgo"
  12 + . "github.com/onsi/gomega"
  13 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  14 +)
  15 +
  16 +var _ = Describe("导入素币兑换清单", func() {
  17 + var (
  18 + activityId int64
  19 + )
  20 + BeforeEach(func() {
  21 +
  22 + _, err1 := pG.DB.QueryOne(
  23 + pg.Scan(&activityId),
  24 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  25 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  26 + Expect(err1).NotTo(HaveOccurred())
  27 + })
  28 + Describe("通过excel文件导入素币兑换清单", func() {
  29 + Context("传入有效的素币兑换清单文件", func() {
  30 + It("返回素币兑换清单导入结果", func() {
  31 + activityIdStr := strconv.FormatInt(activityId, 10)
  32 + fh, _ := os.Open("./files/素币兑换清单模板.xlsx")
  33 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  34 + httpExpect.POST("/cash-pool/activity/exchange-list/import").
  35 + WithFormField("where", "{\"activityId\": \""+activityIdStr+"\", \"uid\": 3289819024952064}").
  36 + WithFile("file", "素币兑换清单模板.xlsx", fh).
  37 + Expect().
  38 + Status(http.StatusOK).
  39 + JSON().
  40 + Object().
  41 + ContainsKey("code").ValueEqual("code", 0).
  42 + ContainsKey("msg").ValueEqual("msg", "ok").
  43 + ContainsKey("data").Value("data").Object()
  44 +
  45 + _ = fh.Close()
  46 + })
  47 + })
  48 + })
  49 + AfterEach(func() {
  50 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  51 + Expect(err).NotTo(HaveOccurred())
  52 + })
  53 +})