package jdshopapi import ( "bytes" "crypto/aes" "crypto/cipher" "encoding/base64" "fmt" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" "golang.org/x/text/encoding/simplifiedchinese" "golang.org/x/text/transform" "io/ioutil" "math" "net/http" "reflect" "sort" "strconv" "testing" ) func TestCreateShopCategory(t *testing.T) { var CreateShopCategoryParams = []*CreateShopCategoryParam{ &CreateShopCategoryParam{ HomeShow: "0", ID: "1", Open: "", OrderNo: "0", ParentID: "", Title: "测试1", Type: "3", }, } result, _ := api.CreateShopCategory(CreateShopCategoryParams) fmt.Println(result) } func TestUpdateStoreStatus(t *testing.T) { err := api.UpdateStoreStatus(24332466, 1) if err != nil { t.Fatal(err) } } func TestNewInfoList(t *testing.T) { result, err := api.NewInfoList(1) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func Test11(t *testing.T) { change := func(s ...string) { s[0] = "Go" s = append(s, "playground") fmt.Println(s) } welcome := []string{"hello", "world"} change(welcome...) fmt.Println(welcome) } func TestAllOrders(t *testing.T) { result, err := api.AllOrders(&AllOrdersParam{ Current: 1, PageSize: 10, //OrderID: "230931583395", //StoreID: "", //OrderStatusArray: nil, //OrderID: "", //OrderCreateDateRange: []string{"2022-01-26 00:00:46", "2022-01-26 17:19:46"}, SelectedTabName: "allOrders", SortName: "desc", }) if err != nil { fmt.Println("err========", err) } t.Log(utils.Format4Output(result, false)) } func TestOrderDetail(t *testing.T) { result, err := api.OrderDetail("213676047946") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestPhoneSensltiveInfo(t *testing.T) { result, err := api.PhoneSensltiveInfo("124396047880", "10b1707dc87755373d488a7a4f422f7d") if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestUpdateWaybill(t *testing.T) { err := api.UpdateWaybill("123076499052", "1274", "88328977356545 ") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestTryGetCookie(t *testing.T) { result, err := api.TryGetCookie() if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestAAADS(t *testing.T) { key, _ := base64.StdEncoding.DecodeString("DW+rL8hlSFt65gUnDXW13A==") data, _ := base64.StdEncoding.DecodeString("Zh1/Gnb3GWkt7slPocCh5EjgfCrivUMrEjQZT+ND2fsDZYGXIny8NazZJ7UA8DgMpuJf9vBPlf3C8l8oT7aYebJMhAEx8kRFdQip8yEFqbzTfHfnNnMsI4Wkh1Ij06iLiZITnPUdWsuHjwI7BKKmZFDloiOkn3p+gtACFThm7B03SfPmvOdokdIQvDa1nEzPL/2DkfhAwDPxzgGHI0HaAQ==") iv, _ := base64.StdEncoding.DecodeString("BBYl0UZhgnV59eP6MkxeeQ==") result, _ := Decrypt(data, key, iv) fmt.Println(string(result)) } func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) { block, err := aes.NewCipher(key) if err != nil { return nil, err } blockMode := cipher.NewCBCDecrypter(block, iv) blockMode.CryptBlocks(decryptBytes, decryptBytes) return PKCS5UnPadding(decryptBytes), nil } func PKCS5UnPadding(decrypted []byte) []byte { length := len(decrypted) unPadding := int(decrypted[length-1]) return decrypted[:(length - unPadding)] } func TestShopDetail(t *testing.T) { //result, err := api.ShopDetail(1000069719) //if err != nil { // t.Fatal(err) //} //t.Log(utils.Format4Output(result, false)) retVal, err := utils.TryStr2Time("2021-07-15 :00") fmt.Println(retVal, err) } func TestSubmitBasic(t *testing.T) { result, err := api.SubmitBasic(&UpdateBasicParam{ StoreName: "京西菜市石犀市场生鲜店", CategoryID2: 62, Coordinate: "30.692941,103.858781", BussinessBeginTime: "08:30", BussinessEndTime: "20:00", ImgURL: "jfs/t1/141918/10/14803/148865/5fb4e8cbE95a606cb/08a8dc277eb97a16.png", StorePhone: "13706546496", AddName: "四川成都市温江区@!温江区锦泉街116号(优取舍)", // AddCode1: 22, // AddCode2: 1930, AddCode3: 49315, CategoryID1: 34, QualificationRequests: []*QualificationRequests{ &QualificationRequests{ QualificationID: 41, QualificationName: "营业执照", QualificationNo: "11111", QualificationURL: "jfs/t1/148622/37/14846/10266/5fb4e3e2Ef2f61870/a7cfba9c1513d95e.png", StartTime: "2020-11-04 00:00:00", EndingTime: "2020-11-06 23:59:59", Time: []string{"2020-11-04 00:00:00", "2020-11-06 23:59:59"}, }, }, }) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestUpdateBasic(t *testing.T) { shop, _ := api.ShopList(1) for _, v := range shop.List { detail, _ := api.ShopDetail(v.StoreID) api.UpdateBasic(&UpdateBasicParam{ StoreID: detail.StoreID, StoreName: detail.StoreName, CategoryID2: 62, Coordinate: detail.Coordinate, BussinessBeginTime: detail.BussinessBeginTime, BussinessEndTime: detail.BussinessEndTime, ImgURL: detail.ImgURL, StorePhone: detail.StorePhone, AddName: utils.LimitUTF8StringLen(detail.AddName, 100), AddCode1: detail.AddCode1, AddCode2: detail.AddCode2, AddCode3: detail.AddCode3, CategoryID1: 34, QualificationRequests: []*QualificationRequests{ &QualificationRequests{ QualificationID: 41, QualificationName: "营业执照", QualificationNo: "91510106MA62QYUK9X", QualificationURL: "jfs/t1/140863/13/17145/275844/5fc9ac7aE9a5f8d68/f9d459176d463cb5.jpg", StartTime: "2017-03-01 00:00:00", EndingTime: "2027-03-01 00:00:00", Time: []string{"2017-03-01 00:00:00", "2027-03-01 00:00:00"}, }, }, }) } // t.Log(utils.Format4Output(result, false)) } func TestUpdateExpand(t *testing.T) { data, _, _ := DownloadFileByURL("http://image.jxc4.com/image/ac6c79112a0330006b40af3302df9f46.jpg") fmt.Println(string(data)) } func TestCreateGisFence(t *testing.T) { err := api.CreateGisFence(1000069001, "3") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestUpdateDeliveryPromise(t *testing.T) { err := api.UpdateDeliveryPromise("09:00", "20:00", 1000070127) if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestUploadImageNew(t *testing.T) { //dp[m][n] = dp[m-1][n] + dp[m][n-1] fmt.Println(myAtoi("21A")) } func myAtoi(s string) (r int) { abs, sign, i, n := 0, 1, 0, len(s) for i < n && s[i] == ' ' { i++ } if i < n { if s[i] == '-' { sign = -1 i++ } else if s[i] == '+' { sign = 1 i++ } } for i < n && s[i] >= '0' && s[i] <= '9' { abs = 10*abs + int(s[i]-'0') //字节 byte '0' == 48 if sign*abs < math.MinInt32 { //整数超过 32 位有符号整数范围 return math.MinInt32 } else if sign*abs > math.MaxInt32 { return math.MaxInt32 } i++ } return r } func minCostClimbingStairs(cost []int) int { min := func(a, b int) int { if a < b { return a } return b } var dp = make([]int, len(cost)) dp[0] = 0 dp[1] = 0 for i := 2; i < len(cost); i++ { dp[i] = min(dp[i-1]+cost[i], dp[i-2]+cost[i-1]) } return dp[len(cost)] } func climbStairs(n int) int { a, b, c := 0, 0, 1 for i := 1; i < n+1; i++ { a = b b = c c = a + b } return c } //leetcode 1876 func countGoodSubstrings(s string) int { if len(s) < 3 { return 0 } count := 0 a, b, c := s[0:1], s[1:2], s[2:3] for i := 3; i < len(s)+1; i++ { if a != b && b != c && a != c { count++ } if i == len(s) { break } a = b b = c c = s[i : i+1] } return count } //T0 = 0, T1 = 1, T2 = 1, 且在 n >= 0 的条件下 Tn+3 = Tn + Tn+1 + Tn+2 func tribonacci(n int) int { if n == 0 || n == 1 { return n } if n == 2 { return 1 } var tris = make([]int, n+1) tris[0] = 0 tris[1] = 1 tris[2] = 1 for i := 3; i < n+1; i++ { tris[i] = tris[i-1] + tris[i-2] + tris[i-3] } return tris[n] } func fib(n int) (result int) { //if n == 0 || n == 1 { // return n //} //var fibs = make([]int, n+1) //fibs[0] = 0 //fibs[1] = 1 //for i := 2; i < n+1; i++ { // fibs[i] = fibs[i-1] + fibs[i-2] //} //return fibs[n] if n == 0 || n == 1 { return n } a, b, c := 0, 0, 1 for i := 2; i < n+1; i++ { a = b b = c c = a + b } return c } //经典dp func dp2(m, n int) (result int) { var dp = make([][]int, m) for i := 0; i < m; i++ { dp[i] = make([]int, n) for j := 0; j < n; j++ { if i == 0 || j == 0 { dp[i][j] = 1 } else { dp[i][j] = dp[i-1][j] + dp[i][j-1] } } } return dp[m-1][n-1] } func a(n int) (ans int) { const mod int = 1e9 + 7 dp := make([][2][3]int, n+1) // 三个维度分别表示:长度,A 的数量,结尾连续 L 的数量 dp[0][0][0] = 1 for i := 1; i <= n; i++ { // 以 P 结尾的数量 for j := 0; j <= 1; j++ { for k := 0; k <= 2; k++ { dp[i][j][0] = (dp[i][j][0] + dp[i-1][j][k]) % mod } } // 以 A 结尾的数量 for k := 0; k <= 2; k++ { dp[i][1][0] = (dp[i][1][0] + dp[i-1][0][k]) % mod } // 以 L 结尾的数量 for j := 0; j <= 1; j++ { for k := 1; k <= 2; k++ { dp[i][j][k] = (dp[i][j][k] + dp[i-1][j][k-1]) % mod } } } for j := 0; j <= 1; j++ { for k := 0; k <= 2; k++ { ans = (ans + dp[n][j][k]) % mod } } return ans } func checkRecord(s string) bool { countL := 0 countA := 0 for _, v := range s { if v == 'A' { countA++ if countA > 1 { return false } } if v == 'L' { countL++ if countL > 2 { return false } } else { countL = 0 } } return true } func sink(array []int, length int) { start := 0 for { //2*n+1 可以画图就知道为什么了,是左边子节点 next := 2*start + 1 if next > length { break } if next+1 <= length && array[next+1] < array[next] { next++ } //上层小于下面,不用互换了 if array[start] <= array[next] { break } //互换继续下沉 array[start], array[next] = array[next], array[start] start = next } } //堆 //top k func topk(s []int, k, i int) { for { left := i*2 + 1 right := i*2 + 2 if i < 0 { break } if right == k { if s[i] < s[left] { s[i], s[left] = s[left], s[i] } } else { if s[i] < s[left] || s[i] < s[right] { if s[left] < s[right] { s[i], s[right] = s[right], s[i] } else { s[i], s[left] = s[left], s[i] } } } if i-1 < 0 { break } i = (i - 1) / 2 } fmt.Println("loop s", s) } //给定一个包含正整数、加(+)、减(-)、乘(*)、除(/)的算数表达式(括号除外),计算其结果。 //表达式仅包含非负整数,+, - ,*,/ 四种运算符和空格  。 整数除法仅保留整数部分。 func calculate(s string) int { return 1 } //输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字。 func spiralOrder(matrix [][]int) []int { var result []int if len(matrix) == 0 { return result } else { if len(matrix[0]) == 0 { return result } } l, h := len(matrix[0]), len(matrix) left, right, top, bottom := 0, l-1, 0, h-1 lmax, tmax := 0, 0 if l%2 == 0 { lmax = l / 2 } else { lmax = l/2 + 1 } if h%2 == 0 { tmax = l / 2 } else { tmax = l/2 + 1 } for left <= lmax && top+1 <= tmax { for left1 := left; left1 <= right; left1++ { if len(result) >= l*h { break } result = append(result, matrix[top][left1]) } if h > 1 { for top1 := top + 1; top1 <= bottom; top1++ { if len(result) >= l*h { break } result = append(result, matrix[top1][right]) } if right > 0 { for right1 := right - 1; right1 >= left; right1-- { if len(result) >= l*h { break } result = append(result, matrix[bottom][right1]) } } if bottom > 0 { for bottom1 := bottom - 1; bottom1 >= top+1; bottom1-- { if len(result) >= l*h { break } result = append(result, matrix[bottom1][left]) } } } left++ top++ right-- bottom-- } return result } func addToArrayForm(A []int, K int) (a []int) { B := []int{} lengthK := 0 for i := 10; ; i = i * 10 { if K/i == 0 { lengthK++ break } lengthK++ } for i := lengthK; i > 0; i-- { if i == lengthK { B = append(B, K/int(math.Pow10(i-1))) } else if i == 1 { gw := K for j := lengthK; j > 1; j-- { gw = gw % int(math.Pow10(j-1)) } B = append(B, gw) } else { qtw := K for j := lengthK; j > 1; j-- { if j == i { qtw = qtw / int(math.Pow10(j-1)) break } else { qtw = qtw % int(math.Pow10(j-1)) } } B = append(B, qtw) } } flag := false in := 0 for k := len(A) - 1; k >= 0; { if flag { break } for k1 := len(B) - 1; k1 >= 0; { if A[k]+B[k1]+in < 10 { if in == 0 { a = append(a, A[k]+B[k1]) } else { a = append(a, A[k]+B[k1]+in) } in = 0 } else { if in == 0 { a = append(a, (A[k]+B[k1])%10) } else { a = append(a, (A[k]+B[k1]+in)%10) } in = 0 in++ } k-- k1-- if k == -1 && k1 == -1 && in != 0 { a = append(a, 1) } if k < 0 { in2 := 0 for i := k1; i >= 0; i-- { if B[i]+in+in2 < 10 { if in2 == 0 { a = append(a, B[i]+in) } else { a = append(a, B[i]+in2+in) } in = 0 in2 = 0 } else { if in2 == 0 { a = append(a, (B[i]+in)%10) } else { a = append(a, (B[i]+in+in2)%10) } in = 0 in2 = 0 in2++ } if i == 0 && in2 != 0 { a = append(a, 1) } } flag = true break } if k1 < 0 { in2 := 0 for i := k; i >= 0; i-- { if A[i]+in+in2 < 10 { if in2 == 0 { a = append(a, A[i]+in) } else { a = append(a, A[i]+in2+in) } in = 0 in2 = 0 } else { if in2 == 0 { a = append(a, (A[i]+in)%10) } else { a = append(a, (A[i]+in+in2)%10) } in = 0 in2 = 0 in2++ } if i == 0 && in2 != 0 { a = append(a, 1) } } flag = true break } } } for i := 0; i < len(a)/2; i++ { temp := a[i] a[i] = a[len(a)-i-1] a[len(a)-i-1] = temp } return a } func maximumProduct(nums []int) int { sort.Ints(nums) n := len(nums) fmt.Println(nums) return max(nums[0]*nums[1]*nums[n-1], nums[n-3]*nums[n-2]*nums[n-1]) } func max(a, b int) int { if a > b { return a } return b } func accountsMerge(accounts [][]string) (ans [][]string) { emailToIndex := map[string]int{} emailToName := map[string]string{} for _, account := range accounts { name := account[0] for _, email := range account[1:] { if _, has := emailToIndex[email]; !has { emailToIndex[email] = len(emailToIndex) emailToName[email] = name } } } fmt.Println(emailToIndex) fmt.Println() fmt.Println(emailToName) parent := make([]int, len(emailToIndex)) for i := range parent { parent[i] = i } var find func(int) int find = func(x int) int { if parent[x] != x { parent[x] = find(parent[x]) } return parent[x] } union := func(from, to int) { parent[find(from)] = find(to) } for _, account := range accounts { firstIndex := emailToIndex[account[1]] for _, email := range account[2:] { union(emailToIndex[email], firstIndex) } } fmt.Println(parent) fmt.Println() fmt.Println(accounts) indexToEmails := map[int][]string{} for email, index := range emailToIndex { index = find(index) indexToEmails[index] = append(indexToEmails[index], email) } fmt.Println(indexToEmails) for _, emails := range indexToEmails { sort.Strings(emails) account := append([]string{emailToName[emails[0]]}, emails...) ans = append(ans, account) } return } func findRedundantConnection(edges [][]int) []int { parent := make([]int, len(edges)+1) for i := range parent { parent[i] = i } fmt.Println("edges ", edges) fmt.Println("parent ", parent) var find func(int) int find = func(x int) int { if parent[x] != x { parent[x] = find(parent[x]) } return parent[x] } union := func(from, to int) bool { fmt.Println(from, to) x, y := find(from), find(to) fmt.Println(x, y) if x == y { return false } parent[x] = y fmt.Println(parent) fmt.Println("-------------------------------") return true } for _, e := range edges { if !union(e[0], e[1]) { return e } } return nil } func removeStones(stones [][]int) int { fa := map[int]int{} var find func(int) int find = func(x int) int { if _, has := fa[x]; !has { fa[x] = x } if fa[x] != x { fa[x] = find(fa[x]) } fmt.Println(fa[x]) return fa[x] } union := func(x, y int) { fmt.Println(x, y) fx, fy := find(x), find(y) if fx == fy { return } fa[fy] = fx fmt.Println(fa) } for _, p := range stones { union(p[0], p[1]+10000) } ans := len(stones) for x, fx := range fa { if x == fx { ans-- } } return ans } //动态规划 func maxUncrossedLines(A []int, B []int) (s int) { var dynamic = make([][]int, len(A)+1, len(A)+1) for index := range dynamic { dynamic[index] = make([]int, len(B)+1, len(B)+1) //多创建一列,因为 index = 0 的时候,没有前置匹配 } for _, v := range dynamic { fmt.Println(v) } fmt.Println("---------------------") for index, a := range A { for i, b := range B { if a == b { dynamic[index+1][i+1] = dynamic[index][i] + 1 for _, v := range dynamic { fmt.Println(v) } fmt.Println("---------------------") } else { dynamic[index+1][i+1] = dynamic[index][i+1] if dynamic[index+1][i+1] < dynamic[index+1][i] { dynamic[index+1][i+1] = dynamic[index+1][i] //判断大小,取大值 } for _, v := range dynamic { fmt.Println(v) } fmt.Println("---------------------") } } } return dynamic[len(A)][len(B)] } func TestShopList(t *testing.T) { result, err := api.ShopList(25) if err != nil { t.Fatal(err) } fmt.Println("aaaaaaa", len(result.List)) t.Log(utils.Format4Output(result, false)) } func TestWareSave(t *testing.T) { // desc := `

因生鲜比较脆弱,发货途中如果有磕碰损坏,请收到联系客服,闪电赔付。请核对好地址,发货后不可修改地址,因改地址导致损坏不能赔付,谢谢理解



` params := &WareSaveParam{ WareID: 0, Height: 100, CategoryID: 13574, LastCategoryID: 13574, VenderID: 10569615, BrandID: 44259, Length: 200, Wide: 100, WareStatus: 8, Title: "散养土鸡蛋新鲜鸡蛋草鸡蛋柴鸡蛋顺丰包邮测试", Weight: "1", ShopCategorys: []int{15602325}, Notes: `



`, Skus: []*WareSaveSkus{ &WareSaveSkus{ // SkuID: 10024685331653, JdPrice: "25", StockNum: 9999, Props: []*WareSaveSkusProp{ &WareSaveSkusProp{ AttrID: 1001027603, AttrValues: 2517633718, AttrValueAlias: "20个", }, }, OuterID: "6045735", }, // &WareSaveSkus{ // JdPrice: "31", // StockNum: 5, // Props: []*WareSaveSkusProp{ // &WareSaveSkusProp{ // AttrID: 1000022043, // AttrValues: 2515430634, // AttrValueAlias: "500g", // }, // }, // }, }, PromiseID: 0, MultiCateProps: []interface{}{}, PropsSet: []interface{}{}, SaleAttrs: []interface{}{}, TransparentImageAudit: []interface{}{}, OptionType: 1, AvailableFeatures: []interface{}{}, CharacteristicService: []interface{}{}, ExtendFeatures: []interface{}{}, TempID: "10569615110055200", //必须要这个东西,不知道是啥 } params.ImageMap.Num0000000000 = append(params.ImageMap.Num0000000000, &CreateSkuParamImages{ ColorID: "0000000000", ImgIndex: 1, ImgURL: "jfs/t1/149724/17/15786/39416/5fbf645aE948e4d7a/b13bcaee129676b2.jpg", // ImgZoneID: "0000000000", }) // , &CreateSkuParamImages{ // ColorID: "0000000000", // ImgIndex: 2, // ImgURL: "jfs/t1/142006/30/15024/504060/5fb636d4Ef12079f7/2adad323cbcf7c52.jpg", // // ImgZoneID: "0000000000", // }) result, err := api.WareSave(params) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } func TestWareDoUpdate(t *testing.T) { err := api.WareDoUpdate("up", "10020536451427") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestStoreWareDoUpdate(t *testing.T) { err := api.StoreWareDoUpdate(1, 10024685331653, "1000063128") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestStoreUpdatePrice(t *testing.T) { err := api.StoreUpdatePrice("16", 10033611936135, "1000116473") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestStoreUpdateStock(t *testing.T) { err := api.StoreUpdateStock(80, 10024685331653, "1000063128") if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestStoreSkuBindStore(t *testing.T) { err := api.StoreSkuBindStore(false, []string{"10024685331653"}, []string{"1000063128"}) if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestSetOrderStateToWait(t *testing.T) { err := api.SetOrderStateToWait(1) if err != nil { t.Fatal(err) } // t.Log(utils.Format4Output(result, false)) } func TestStoreProductSearch(t *testing.T) { result, _, err := api.StoreProductSearch(1, 20, []string{"1000069025"}) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } //二进制转十六进制 func btox(b string) string { base, _ := strconv.ParseInt(b, 2, 10) return strconv.FormatInt(base, 16) } //十六进制转二进制 func xtob(x string) string { base, _ := strconv.ParseInt(x, 16, 10) return strconv.FormatInt(base, 2) } func h8l82int(h, l string) (i int64) { s1, s2 := xtob(h), xtob(l) flag1 := 8 - len(s1) flag2 := 8 - len(s2) for m := 0; m < flag1; m++ { s1 = "0" + s1 } for j := 0; j < flag2; j++ { s2 = "0" + s2 } i, _ = strconv.ParseInt(s1+s2, 2, 32) return i } func TestUpdateStatus(t *testing.T) { data, _, err := DownloadFileByURL("http://image.jxc4.com/1586923030origin57f8b9d4N9ec3cb41.jpg") fmt.Println(data, err) } func sss() (data2 []byte) { dataLen := 34 data2 = make([]byte, 2) data2[0] = (uint8)((dataLen & 0xFF00) >> 8) data2[1] = (uint8)(dataLen & 0xFF) return data2 } func Utf8ToGbk(str []byte) (b []byte, err error) { r := transform.NewReader(bytes.NewReader(str), simplifiedchinese.GBK.NewEncoder()) b, err = ioutil.ReadAll(r) if err != nil { return } return } func int2h8l8(i int64) (h, l string) { origin2 := fmt.Sprintf("%b", i) flag := 16 - len(origin2) for i := 0; i < flag; i++ { origin2 = "0" + origin2 } begin8 := origin2[:8] end8 := origin2[8:] r1, _ := strconv.ParseInt(begin8, 2, 32) r2, _ := strconv.ParseInt(end8, 2, 32) h = fmt.Sprintf("%x", r1) l = fmt.Sprintf("%x", r2) if len(h) < 2 { h = "0" + h } if len(l) < 2 { l = "0" + l } return h, l } func Hextob(str string) []byte { slen := len(str) bHex := make([]byte, len(str)/2) ii := 0 for i := 0; i < len(str); i = i + 2 { if slen != 1 { ss := string(str[i]) + string(str[i+1]) bt, _ := strconv.ParseInt(ss, 16, 32) bHex[ii] = byte(bt) ii = ii + 1 slen = slen - 2 } } return bHex } func TestAPI_AllOrders(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { allOrdersParam *AllOrdersParam } tests := []struct { name string fields fields args args wantAllOrdersResult *AllOrdersResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotAllOrdersResult, err := a.AllOrders(tt.args.allOrdersParam) if (err != nil) != tt.wantErr { t.Errorf("AllOrders() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotAllOrdersResult, tt.wantAllOrdersResult) { t.Errorf("AllOrders() gotAllOrdersResult = %v, want %v", gotAllOrdersResult, tt.wantAllOrdersResult) } }) } } func TestAPI_AccessAPI(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { action string url string bizParams map[string]interface{} } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessAPI(tt.args.action, tt.args.url, tt.args.bizParams) if (err != nil) != tt.wantErr { t.Errorf("AccessAPI() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessAPI() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AccessAPI2(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { action string pURL string bizParams map[string]interface{} } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessAPI2(tt.args.action, tt.args.pURL, tt.args.bizParams) if (err != nil) != tt.wantErr { t.Errorf("AccessAPI2() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessAPI2() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AccessStorePage(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { fullURL string bizParams map[string]interface{} isPost bool } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessStorePage(tt.args.fullURL, tt.args.bizParams, tt.args.isPost) if (err != nil) != tt.wantErr { t.Errorf("AccessStorePage() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessStorePage() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AccessStorePage2(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { fullURL string bizParams map[string]interface{} isPost bool } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessStorePage2(tt.args.fullURL, tt.args.bizParams, tt.args.isPost) if (err != nil) != tt.wantErr { t.Errorf("AccessStorePage2() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessStorePage2() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AccessStorePage3(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { data []byte fileName string } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessStorePage3(tt.args.data, tt.args.fileName) if (err != nil) != tt.wantErr { t.Errorf("AccessStorePage3() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessStorePage3() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AccessStorePage4(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { fullURL string param string isPost bool } tests := []struct { name string fields fields args args wantRetVal map[string]interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotRetVal, err := a.AccessStorePage4(tt.args.fullURL, tt.args.param, tt.args.isPost) if (err != nil) != tt.wantErr { t.Errorf("AccessStorePage4() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotRetVal, tt.wantRetVal) { t.Errorf("AccessStorePage4() gotRetVal = %v, want %v", gotRetVal, tt.wantRetVal) } }) } } func TestAPI_AllOrders1(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { allOrdersParam *AllOrdersParam } tests := []struct { name string fields fields args args wantAllOrdersResult *AllOrdersResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotAllOrdersResult, err := a.AllOrders(tt.args.allOrdersParam) if (err != nil) != tt.wantErr { t.Errorf("AllOrders() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotAllOrdersResult, tt.wantAllOrdersResult) { t.Errorf("AllOrders() gotAllOrdersResult = %v, want %v", gotAllOrdersResult, tt.wantAllOrdersResult) } }) } } func TestAPI_CreateEntityStore(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { createEntityStoreParam *CreateEntityStoreParam } tests := []struct { name string fields fields args args wantVendorStoreID string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotVendorStoreID, err := a.CreateEntityStore(tt.args.createEntityStoreParam) if (err != nil) != tt.wantErr { t.Errorf("CreateEntityStore() error = %v, wantErr %v", err, tt.wantErr) return } if gotVendorStoreID != tt.wantVendorStoreID { t.Errorf("CreateEntityStore() gotVendorStoreID = %v, want %v", gotVendorStoreID, tt.wantVendorStoreID) } }) } } func TestAPI_CreateGisFence(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int kilometres string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.CreateGisFence(tt.args.storeID, tt.args.kilometres); (err != nil) != tt.wantErr { t.Errorf("CreateGisFence() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_CreateShopCategory(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { createShopCategoryParam []*CreateShopCategoryParam } tests := []struct { name string fields fields args args wantStatus int64 wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotStatus, err := a.CreateShopCategory(tt.args.createShopCategoryParam) if (err != nil) != tt.wantErr { t.Errorf("CreateShopCategory() error = %v, wantErr %v", err, tt.wantErr) return } if gotStatus != tt.wantStatus { t.Errorf("CreateShopCategory() gotStatus = %v, want %v", gotStatus, tt.wantStatus) } }) } } func TestAPI_CreateWare(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { createSkuParamWare *CreateSkuParamWare createSkuParamSkus []*CreateSkuParamSkus } tests := []struct { name string fields fields args args wantCreateSkuResult *CreateSkuResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotCreateSkuResult, err := a.CreateWare(tt.args.createSkuParamWare, tt.args.createSkuParamSkus) if (err != nil) != tt.wantErr { t.Errorf("CreateWare() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotCreateSkuResult, tt.wantCreateSkuResult) { t.Errorf("CreateWare() gotCreateSkuResult = %v, want %v", gotCreateSkuResult, tt.wantCreateSkuResult) } }) } } func TestAPI_DeleteShopCategory(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { cid int64 } tests := []struct { name string fields fields args args wantUniteResp *UniteResp wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotUniteResp, err := a.DeleteShopCategory(tt.args.cid) if (err != nil) != tt.wantErr { t.Errorf("DeleteShopCategory() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotUniteResp, tt.wantUniteResp) { t.Errorf("DeleteShopCategory() gotUniteResp = %v, want %v", gotUniteResp, tt.wantUniteResp) } }) } } func TestAPI_DeleteSku(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.DeleteSku(tt.args.skuId); (err != nil) != tt.wantErr { t.Errorf("DeleteSku() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_DeleteStoresByID(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeId int64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.DeleteStoresByID(tt.args.storeId); (err != nil) != tt.wantErr { t.Errorf("DeleteStoresByID() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_DeleteWare(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.DeleteWare(tt.args.wareId); (err != nil) != tt.wantErr { t.Errorf("DeleteWare() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_FindAttrs(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { cid int } tests := []struct { name string fields fields args args wantFindAttrsResult []*FindAttrsResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindAttrsResult, err := a.FindAttrs(tt.args.cid) if (err != nil) != tt.wantErr { t.Errorf("FindAttrs() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindAttrsResult, tt.wantFindAttrsResult) { t.Errorf("FindAttrs() gotFindAttrsResult = %v, want %v", gotFindAttrsResult, tt.wantFindAttrsResult) } }) } } func TestAPI_FindOpReason(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 } tests := []struct { name string fields fields args args wantReason string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotReason, err := a.FindOpReason(tt.args.wareId) if (err != nil) != tt.wantErr { t.Errorf("FindOpReason() error = %v, wantErr %v", err, tt.wantErr) return } if gotReason != tt.wantReason { t.Errorf("FindOpReason() gotReason = %v, want %v", gotReason, tt.wantReason) } }) } } func TestAPI_FindShopCategories(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantFindShopCategoriesResult []*FindShopCategoriesResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindShopCategoriesResult, err := a.FindShopCategories() if (err != nil) != tt.wantErr { t.Errorf("FindShopCategories() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindShopCategoriesResult, tt.wantFindShopCategoriesResult) { t.Errorf("FindShopCategories() gotFindShopCategoriesResult = %v, want %v", gotFindShopCategoriesResult, tt.wantFindShopCategoriesResult) } }) } } func TestAPI_FindSkuById(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int64 } tests := []struct { name string fields fields args args wantFindSkuByIdParam *FindSkuByIdParam wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindSkuByIdParam, err := a.FindSkuById(tt.args.skuId) if (err != nil) != tt.wantErr { t.Errorf("FindSkuById() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindSkuByIdParam, tt.wantFindSkuByIdParam) { t.Errorf("FindSkuById() gotFindSkuByIdParam = %v, want %v", gotFindSkuByIdParam, tt.wantFindSkuByIdParam) } }) } } func TestAPI_FindSkuSiteStock(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { siteId int skuId int64 } tests := []struct { name string fields fields args args wantFindSkuSiteStockResult *FindSkuSiteStockResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindSkuSiteStockResult, err := a.FindSkuSiteStock(tt.args.siteId, tt.args.skuId) if (err != nil) != tt.wantErr { t.Errorf("FindSkuSiteStock() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindSkuSiteStockResult, tt.wantFindSkuSiteStockResult) { t.Errorf("FindSkuSiteStock() gotFindSkuSiteStockResult = %v, want %v", gotFindSkuSiteStockResult, tt.wantFindSkuSiteStockResult) } }) } } func TestAPI_FindSkuStock(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.FindSkuStock(tt.args.skuId); (err != nil) != tt.wantErr { t.Errorf("FindSkuStock() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_FindStoreInfoByExtStoreId(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int } tests := []struct { name string fields fields args args wantQueryEntityStoreResult *QueryEntityStoreResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotQueryEntityStoreResult, err := a.FindStoreInfoByExtStoreId(tt.args.storeID) if (err != nil) != tt.wantErr { t.Errorf("FindStoreInfoByExtStoreId() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotQueryEntityStoreResult, tt.wantQueryEntityStoreResult) { t.Errorf("FindStoreInfoByExtStoreId() gotQueryEntityStoreResult = %v, want %v", gotQueryEntityStoreResult, tt.wantQueryEntityStoreResult) } }) } } func TestAPI_FindValuesByAttrId(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { categoryAttrId int } tests := []struct { name string fields fields args args wantFindValuesByAttrIdResult []*FindValuesByAttrIdResult wantMaxOrder int wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindValuesByAttrIdResult, gotMaxOrder, err := a.FindValuesByAttrId(tt.args.categoryAttrId) if (err != nil) != tt.wantErr { t.Errorf("FindValuesByAttrId() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindValuesByAttrIdResult, tt.wantFindValuesByAttrIdResult) { t.Errorf("FindValuesByAttrId() gotFindValuesByAttrIdResult = %v, want %v", gotFindValuesByAttrIdResult, tt.wantFindValuesByAttrIdResult) } if gotMaxOrder != tt.wantMaxOrder { t.Errorf("FindValuesByAttrId() gotMaxOrder = %v, want %v", gotMaxOrder, tt.wantMaxOrder) } }) } } func TestAPI_FindVendorCategories(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantFindVendorCategoriesResult []*FindVendorCategoriesResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindVendorCategoriesResult, err := a.FindVendorCategories() if (err != nil) != tt.wantErr { t.Errorf("FindVendorCategories() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindVendorCategoriesResult, tt.wantFindVendorCategoriesResult) { t.Errorf("FindVendorCategories() gotFindVendorCategoriesResult = %v, want %v", gotFindVendorCategoriesResult, tt.wantFindVendorCategoriesResult) } }) } } func TestAPI_FindWareById(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 } tests := []struct { name string fields fields args args wantFindWareByIdResult *FindWareByIdResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFindWareByIdResult, err := a.FindWareById(tt.args.wareId) if (err != nil) != tt.wantErr { t.Errorf("FindWareById() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotFindWareByIdResult, tt.wantFindWareByIdResult) { t.Errorf("FindWareById() gotFindWareByIdResult = %v, want %v", gotFindWareByIdResult, tt.wantFindWareByIdResult) } }) } } func TestAPI_GetAttrsByCategoryId(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { currPage int pageSize int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.GetAttrsByCategoryId(tt.args.currPage, tt.args.pageSize); (err != nil) != tt.wantErr { t.Errorf("GetAttrsByCategoryId() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_GetCallbackMsg(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { request *http.Request } tests := []struct { name string fields fields args args wantCall *CallBackResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotCall, err := a.GetCallbackMsg(tt.args.request) if (err != nil) != tt.wantErr { t.Errorf("GetCallbackMsg() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotCall, tt.wantCall) { t.Errorf("GetCallbackMsg() gotCall = %v, want %v", gotCall, tt.wantCall) } }) } } func TestAPI_GetCity(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { parentID int } tests := []struct { name string fields fields args args wantGetAddressCodeResult []*GetAddressCodeResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotGetAddressCodeResult, err := a.GetCity(tt.args.parentID) if (err != nil) != tt.wantErr { t.Errorf("GetCity() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotGetAddressCodeResult, tt.wantGetAddressCodeResult) { t.Errorf("GetCity() gotGetAddressCodeResult = %v, want %v", gotGetAddressCodeResult, tt.wantGetAddressCodeResult) } }) } } func TestAPI_GetCounty(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { parentID int } tests := []struct { name string fields fields args args wantGetAddressCodeResult []*GetAddressCodeResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotGetAddressCodeResult, err := a.GetCounty(tt.args.parentID) if (err != nil) != tt.wantErr { t.Errorf("GetCounty() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotGetAddressCodeResult, tt.wantGetAddressCodeResult) { t.Errorf("GetCounty() gotGetAddressCodeResult = %v, want %v", gotGetAddressCodeResult, tt.wantGetAddressCodeResult) } }) } } func TestAPI_GetDeliveryCompany(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantResult interface{} wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotResult, err := a.GetDeliveryCompany() if (err != nil) != tt.wantErr { t.Errorf("GetDeliveryCompany() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotResult, tt.wantResult) { t.Errorf("GetDeliveryCompany() gotResult = %v, want %v", gotResult, tt.wantResult) } }) } } func TestAPI_GetFeightMb(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.GetFeightMb(); (err != nil) != tt.wantErr { t.Errorf("GetFeightMb() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_GetOrder(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderID int64 isStatus bool } tests := []struct { name string fields fields args args wantGetOrderResult *GetOrderResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotGetOrderResult, err := a.GetOrder(tt.args.orderID, tt.args.isStatus) if (err != nil) != tt.wantErr { t.Errorf("GetOrder() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotGetOrderResult, tt.wantGetOrderResult) { t.Errorf("GetOrder() gotGetOrderResult = %v, want %v", gotGetOrderResult, tt.wantGetOrderResult) } }) } } func TestAPI_GetOrderExtInfoByOrderId(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId string } tests := []struct { name string fields fields args args wantTime string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotTime, err := a.GetOrderExtInfoByOrderId(tt.args.orderId) if (err != nil) != tt.wantErr { t.Errorf("GetOrderExtInfoByOrderId() error = %v, wantErr %v", err, tt.wantErr) return } if gotTime != tt.wantTime { t.Errorf("GetOrderExtInfoByOrderId() gotTime = %v, want %v", gotTime, tt.wantTime) } }) } } func TestAPI_GetProvince(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantGetAddressCodeResult []*GetAddressCodeResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotGetAddressCodeResult, err := a.GetProvince() if (err != nil) != tt.wantErr { t.Errorf("GetProvince() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotGetAddressCodeResult, tt.wantGetAddressCodeResult) { t.Errorf("GetProvince() gotGetAddressCodeResult = %v, want %v", gotGetAddressCodeResult, tt.wantGetAddressCodeResult) } }) } } func TestAPI_ImageUpdate(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 imgIndex int imgUrl string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.ImageUpdate(tt.args.wareId, tt.args.imgIndex, tt.args.imgUrl); (err != nil) != tt.wantErr { t.Errorf("ImageUpdate() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_JdSSO(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.JdSSO(); (err != nil) != tt.wantErr { t.Errorf("JdSSO() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_KeyGet(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantKeyGetResult *KeyGetResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotKeyGetResult, err := a.KeyGet() if (err != nil) != tt.wantErr { t.Errorf("KeyGet() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotKeyGetResult, tt.wantKeyGetResult) { t.Errorf("KeyGet() gotKeyGetResult = %v, want %v", gotKeyGetResult, tt.wantKeyGetResult) } }) } } func TestAPI_NewInfoList(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int64 } tests := []struct { name string fields fields args args wantNewInfoListResult *NewInfoListResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotNewInfoListResult, err := a.NewInfoList(tt.args.storeID) if (err != nil) != tt.wantErr { t.Errorf("NewInfoList() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotNewInfoListResult, tt.wantNewInfoListResult) { t.Errorf("NewInfoList() gotNewInfoListResult = %v, want %v", gotNewInfoListResult, tt.wantNewInfoListResult) } }) } } func TestAPI_OrderDetail(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId string } tests := []struct { name string fields fields args args wantOrderDetailResult *OrderDetailResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotOrderDetailResult, err := a.OrderDetail(tt.args.orderId) if (err != nil) != tt.wantErr { t.Errorf("OrderDetail() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotOrderDetailResult, tt.wantOrderDetailResult) { t.Errorf("OrderDetail() gotOrderDetailResult = %v, want %v", gotOrderDetailResult, tt.wantOrderDetailResult) } }) } } func TestAPI_OrderShipment(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderID int64 logiCoprId string logiNo string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.OrderShipment(tt.args.orderID, tt.args.logiCoprId, tt.args.logiNo); (err != nil) != tt.wantErr { t.Errorf("OrderShipment() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_PhoneSensltiveInfo(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId string accessKey string } tests := []struct { name string fields fields args args wantFakeMobile string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotFakeMobile, err := a.PhoneSensltiveInfo(tt.args.orderId, tt.args.accessKey) if (err != nil) != tt.wantErr { t.Errorf("PhoneSensltiveInfo() error = %v, wantErr %v", err, tt.wantErr) return } if gotFakeMobile != tt.wantFakeMobile { t.Errorf("PhoneSensltiveInfo() gotFakeMobile = %v, want %v", gotFakeMobile, tt.wantFakeMobile) } }) } } func TestAPI_QueryEntityStore(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeId int64 } tests := []struct { name string fields fields args args wantQueryEntityStoreResult *QueryEntityStoreResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotQueryEntityStoreResult, err := a.QueryEntityStore(tt.args.storeId) if (err != nil) != tt.wantErr { t.Errorf("QueryEntityStore() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotQueryEntityStoreResult, tt.wantQueryEntityStoreResult) { t.Errorf("QueryEntityStore() gotQueryEntityStoreResult = %v, want %v", gotQueryEntityStoreResult, tt.wantQueryEntityStoreResult) } }) } } func TestAPI_QueryPicture(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { pictureName string } tests := []struct { name string fields fields args args wantQueryPictureReuslt []*QueryPictureReuslt wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotQueryPictureReuslt, err := a.QueryPicture(tt.args.pictureName) if (err != nil) != tt.wantErr { t.Errorf("QueryPicture() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotQueryPictureReuslt, tt.wantQueryPictureReuslt) { t.Errorf("QueryPicture() gotQueryPictureReuslt = %v, want %v", gotQueryPictureReuslt, tt.wantQueryPictureReuslt) } }) } } func TestAPI_SaveVenderAttrValue(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { attValue string attributeId int categoryId int indexId int } tests := []struct { name string fields fields args args wantCategoryAttrId int64 wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotCategoryAttrId, err := a.SaveVenderAttrValue(tt.args.attValue, tt.args.attributeId, tt.args.categoryId, tt.args.indexId) if (err != nil) != tt.wantErr { t.Errorf("SaveVenderAttrValue() error = %v, wantErr %v", err, tt.wantErr) return } if gotCategoryAttrId != tt.wantCategoryAttrId { t.Errorf("SaveVenderAttrValue() gotCategoryAttrId = %v, want %v", gotCategoryAttrId, tt.wantCategoryAttrId) } }) } } func TestAPI_SearchSkuList(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { pageNo int pageSize int } tests := []struct { name string fields fields args args wantList []*SearchSkuListResult wantTotalCount int wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotList, gotTotalCount, err := a.SearchSkuList(tt.args.pageNo, tt.args.pageSize) if (err != nil) != tt.wantErr { t.Errorf("SearchSkuList() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotList, tt.wantList) { t.Errorf("SearchSkuList() gotList = %v, want %v", gotList, tt.wantList) } if gotTotalCount != tt.wantTotalCount { t.Errorf("SearchSkuList() gotTotalCount = %v, want %v", gotTotalCount, tt.wantTotalCount) } }) } } func TestAPI_SearchSkuList2(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareIDs []int } tests := []struct { name string fields fields args args wantList []*SearchSkuListResult wantTotalCount int wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotList, gotTotalCount, err := a.SearchSkuList2(tt.args.wareIDs) if (err != nil) != tt.wantErr { t.Errorf("SearchSkuList2() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotList, tt.wantList) { t.Errorf("SearchSkuList2() gotList = %v, want %v", gotList, tt.wantList) } if gotTotalCount != tt.wantTotalCount { t.Errorf("SearchSkuList2() gotTotalCount = %v, want %v", gotTotalCount, tt.wantTotalCount) } }) } } func TestAPI_SearchWare4Valid(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { searchKey string pageNo int pageSize int } tests := []struct { name string fields fields args args wantSearchWare4ValidResult *SearchWare4ValidResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotSearchWare4ValidResult, err := a.SearchWare4Valid(tt.args.searchKey, tt.args.pageNo, tt.args.pageSize) if (err != nil) != tt.wantErr { t.Errorf("SearchWare4Valid() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotSearchWare4ValidResult, tt.wantSearchWare4ValidResult) { t.Errorf("SearchWare4Valid() gotSearchWare4ValidResult = %v, want %v", gotSearchWare4ValidResult, tt.wantSearchWare4ValidResult) } }) } } func TestAPI_SetOrderStateToFinish(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId int64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.SetOrderStateToFinish(tt.args.orderId); (err != nil) != tt.wantErr { t.Errorf("SetOrderStateToFinish() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_SetOrderStateToWait(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId int64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.SetOrderStateToWait(tt.args.orderId); (err != nil) != tt.wantErr { t.Errorf("SetOrderStateToWait() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_ShopDetail(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int } tests := []struct { name string fields fields args args wantShopDetailResult *ShopDetailResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotShopDetailResult, err := a.ShopDetail(tt.args.storeID) if (err != nil) != tt.wantErr { t.Errorf("ShopDetail() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotShopDetailResult, tt.wantShopDetailResult) { t.Errorf("ShopDetail() gotShopDetailResult = %v, want %v", gotShopDetailResult, tt.wantShopDetailResult) } }) } } func TestAPI_ShopList(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { pageNum int } tests := []struct { name string fields fields args args wantShopDetailResult *ShopListResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotShopDetailResult, err := a.ShopList(tt.args.pageNum) if (err != nil) != tt.wantErr { t.Errorf("ShopList() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotShopDetailResult, tt.wantShopDetailResult) { t.Errorf("ShopList() gotShopDetailResult = %v, want %v", gotShopDetailResult, tt.wantShopDetailResult) } }) } } func TestAPI_StoreProductSearch(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { pageNo int pageSize int vendorStoreIDs []string } tests := []struct { name string fields fields args args wantStoreProductSearchResult []*StoreProductSearchResult wantTotalCount int wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotStoreProductSearchResult, gotTotalCount, err := a.StoreProductSearch(tt.args.pageNo, tt.args.pageSize, tt.args.vendorStoreIDs) if (err != nil) != tt.wantErr { t.Errorf("StoreProductSearch() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotStoreProductSearchResult, tt.wantStoreProductSearchResult) { t.Errorf("StoreProductSearch() gotStoreProductSearchResult = %v, want %v", gotStoreProductSearchResult, tt.wantStoreProductSearchResult) } if gotTotalCount != tt.wantTotalCount { t.Errorf("StoreProductSearch() gotTotalCount = %v, want %v", gotTotalCount, tt.wantTotalCount) } }) } } func TestAPI_StoreSkuBindStore(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { allStore bool skuIds []string vendorStoreIDs []string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.StoreSkuBindStore(tt.args.allStore, tt.args.skuIds, tt.args.vendorStoreIDs); (err != nil) != tt.wantErr { t.Errorf("StoreSkuBindStore() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_StoreUpdatePrice(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { price string skuId int64 vendorStoreID string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.StoreUpdatePrice(tt.args.price, tt.args.skuId, tt.args.vendorStoreID); (err != nil) != tt.wantErr { t.Errorf("StoreUpdatePrice() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_StoreUpdateStock(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { stockNum int skuId int64 vendorStoreID string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.StoreUpdateStock(tt.args.stockNum, tt.args.skuId, tt.args.vendorStoreID); (err != nil) != tt.wantErr { t.Errorf("StoreUpdateStock() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_StoreWareDoUpdate(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { status int skuId int64 vendorStoreID string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.StoreWareDoUpdate(tt.args.status, tt.args.skuId, tt.args.vendorStoreID); (err != nil) != tt.wantErr { t.Errorf("StoreWareDoUpdate() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_SubmitBasic(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { updateBasicParam *UpdateBasicParam } tests := []struct { name string fields fields args args wantVendorStoreID int64 wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotVendorStoreID, err := a.SubmitBasic(tt.args.updateBasicParam) if (err != nil) != tt.wantErr { t.Errorf("SubmitBasic() error = %v, wantErr %v", err, tt.wantErr) return } if gotVendorStoreID != tt.wantVendorStoreID { t.Errorf("SubmitBasic() gotVendorStoreID = %v, want %v", gotVendorStoreID, tt.wantVendorStoreID) } }) } } func TestAPI_TransparentImageAdd(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 imageUrl string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.TransparentImageAdd(tt.args.wareId, tt.args.imageUrl); (err != nil) != tt.wantErr { t.Errorf("TransparentImageAdd() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_TryGetCookie(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantCookie string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotCookie, err := a.TryGetCookie() if (err != nil) != tt.wantErr { t.Errorf("TryGetCookie() error = %v, wantErr %v", err, tt.wantErr) return } if gotCookie != tt.wantCookie { t.Errorf("TryGetCookie() gotCookie = %v, want %v", gotCookie, tt.wantCookie) } }) } } func TestAPI_UpOrDown(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 opType int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpOrDown(tt.args.wareId, tt.args.opType); (err != nil) != tt.wantErr { t.Errorf("UpOrDown() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateBasic(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { updateBasicParam *UpdateBasicParam } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateBasic(tt.args.updateBasicParam); (err != nil) != tt.wantErr { t.Errorf("UpdateBasic() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateDeliveryPromise(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { start string end string storeID int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateDeliveryPromise(tt.args.start, tt.args.end, tt.args.storeID); (err != nil) != tt.wantErr { t.Errorf("UpdateDeliveryPromise() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateEntityStore(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { updateEntityStoreParam *UpdateEntityStoreParam } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateEntityStore(tt.args.updateEntityStoreParam); (err != nil) != tt.wantErr { t.Errorf("UpdateEntityStore() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateExpand(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateExpand(tt.args.storeID); (err != nil) != tt.wantErr { t.Errorf("UpdateExpand() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateSkuJdPrice(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int jdPrice float64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateSkuJdPrice(tt.args.skuId, tt.args.jdPrice); (err != nil) != tt.wantErr { t.Errorf("UpdateSkuJdPrice() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateSkuSiteStock(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int64 stockNum int siteId int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateSkuSiteStock(tt.args.skuId, tt.args.stockNum, tt.args.siteId); (err != nil) != tt.wantErr { t.Errorf("UpdateSkuSiteStock() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateSkuStock(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { skuId int stockNum int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateSkuStock(tt.args.skuId, tt.args.stockNum); (err != nil) != tt.wantErr { t.Errorf("UpdateSkuStock() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateSkus(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { updateSkusParam *UpdateSkusParam } tests := []struct { name string fields fields args args wantVendorSkuID string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotVendorSkuID, err := a.UpdateSkus(tt.args.updateSkusParam) if (err != nil) != tt.wantErr { t.Errorf("UpdateSkus() error = %v, wantErr %v", err, tt.wantErr) return } if gotVendorSkuID != tt.wantVendorSkuID { t.Errorf("UpdateSkus() gotVendorSkuID = %v, want %v", gotVendorSkuID, tt.wantVendorSkuID) } }) } } func TestAPI_UpdateStatus(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int storeStatus int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateStatus(tt.args.storeID, tt.args.storeStatus); (err != nil) != tt.wantErr { t.Errorf("UpdateStatus() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateStoreStatus(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int storeStatus int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateStoreStatus(tt.args.storeID, tt.args.storeStatus); (err != nil) != tt.wantErr { t.Errorf("UpdateStoreStatus() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateStoreStatusAPI(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { storeID int status int } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateStoreStatusAPI(tt.args.storeID, tt.args.status); (err != nil) != tt.wantErr { t.Errorf("UpdateStoreStatusAPI() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateWare(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { updateWareParam *UpdateWareParam } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateWare(tt.args.updateWareParam); (err != nil) != tt.wantErr { t.Errorf("UpdateWare() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateWareMarketPrice(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareId int64 marketPrice float64 } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateWareMarketPrice(tt.args.wareId, tt.args.marketPrice); (err != nil) != tt.wantErr { t.Errorf("UpdateWareMarketPrice() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateWareSaleAttrvalueAlias(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { param *UpdateWareSaleAttrvalueAliasParam } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateWareSaleAttrvalueAlias(tt.args.param); (err != nil) != tt.wantErr { t.Errorf("UpdateWareSaleAttrvalueAlias() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UpdateWaybill(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { orderId string logiId string logiNo string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.UpdateWaybill(tt.args.orderId, tt.args.logiId, tt.args.logiNo); (err != nil) != tt.wantErr { t.Errorf("UpdateWaybill() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_UploadImageNew(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { data []byte fileName string } tests := []struct { name string fields fields args args wantJdURL string wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotJdURL, err := a.UploadImageNew(tt.args.data, tt.args.fileName) if (err != nil) != tt.wantErr { t.Errorf("UploadImageNew() error = %v, wantErr %v", err, tt.wantErr) return } if gotJdURL != tt.wantJdURL { t.Errorf("UploadImageNew() gotJdURL = %v, want %v", gotJdURL, tt.wantJdURL) } }) } } func TestAPI_UploadPicture(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { imageData []byte pictureCateID int pictureName string } tests := []struct { name string fields fields args args wantUploadPictureResult *UploadPictureResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotUploadPictureResult, err := a.UploadPicture(tt.args.imageData, tt.args.pictureCateID, tt.args.pictureName) if (err != nil) != tt.wantErr { t.Errorf("UploadPicture() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotUploadPictureResult, tt.wantUploadPictureResult) { t.Errorf("UploadPicture() gotUploadPictureResult = %v, want %v", gotUploadPictureResult, tt.wantUploadPictureResult) } }) } } func TestAPI_VoucherInfoGet(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } tests := []struct { name string fields fields wantVoucherInfoGetResult *VoucherInfoGetResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotVoucherInfoGetResult, err := a.VoucherInfoGet() if (err != nil) != tt.wantErr { t.Errorf("VoucherInfoGet() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotVoucherInfoGetResult, tt.wantVoucherInfoGetResult) { t.Errorf("VoucherInfoGet() gotVoucherInfoGetResult = %v, want %v", gotVoucherInfoGetResult, tt.wantVoucherInfoGetResult) } }) } } func TestAPI_WareDoUpdate(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { op string updateWareIds string } tests := []struct { name string fields fields args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if err := a.WareDoUpdate(tt.args.op, tt.args.updateWareIds); (err != nil) != tt.wantErr { t.Errorf("WareDoUpdate() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestAPI_WareSave(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { wareSaveParam *WareSaveParam } tests := []struct { name string fields fields args args wantWareSaveResult []*WareSaveResult wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } gotWareSaveResult, err := a.WareSave(tt.args.wareSaveParam) if (err != nil) != tt.wantErr { t.Errorf("WareSave() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotWareSaveResult, tt.wantWareSaveResult) { t.Errorf("WareSave() gotWareSaveResult = %v, want %v", gotWareSaveResult, tt.wantWareSaveResult) } }) } } func TestAPI_signParam(t *testing.T) { type fields struct { APICookie platformapi.APICookie accessToken string appKey string appSecret string client *http.Client config *platformapi.APIConfig } type args struct { params map[string]interface{} } tests := []struct { name string fields fields args args wantSig string }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { a := &API{ APICookie: tt.fields.APICookie, accessToken: tt.fields.accessToken, appKey: tt.fields.appKey, appSecret: tt.fields.appSecret, client: tt.fields.client, config: tt.fields.config, } if gotSig := a.signParam(tt.args.params); gotSig != tt.wantSig { t.Errorf("signParam() = %v, want %v", gotSig, tt.wantSig) } }) } } func TestNew(t *testing.T) { type args struct { accessToken string appKey string appSecret string config []*platformapi.APIConfig } tests := []struct { name string args args want *API }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := New(tt.args.accessToken, tt.args.appKey, tt.args.appSecret, tt.args.config...); !reflect.DeepEqual(got, tt.want) { t.Errorf("New() = %v, want %v", got, tt.want) } }) } } func TestRandStringBytes(t *testing.T) { type args struct { n int } tests := []struct { name string args args want string }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := RandStringBytes(tt.args.n); got != tt.want { t.Errorf("RandStringBytes() = %v, want %v", got, tt.want) } }) } } func Test_getBoundary(t *testing.T) { tests := []struct { name string wantBoundary string }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if gotBoundary := getBoundary(); gotBoundary != tt.wantBoundary { t.Errorf("getBoundary() = %v, want %v", gotBoundary, tt.wantBoundary) } }) } }