- showapi.GetProductInfoByBarCode
This commit is contained in:
51
platformapi/showapi/barcode_test.go
Normal file
51
platformapi/showapi/barcode_test.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package showapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func TestGetProductInfoByBarCode(t *testing.T) {
|
||||
result, err := api.GetProductInfoByBarCode("6943924100033")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestSplitProductSpec(t *testing.T) {
|
||||
testData := []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"spec": "9张/包",
|
||||
"specQuality": 9,
|
||||
"specUnit": "张",
|
||||
"unit": "包",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"spec": "300克",
|
||||
"specQuality": 300,
|
||||
"specUnit": "克",
|
||||
"unit": "",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"spec": "ffff",
|
||||
"specQuality": 0,
|
||||
"specUnit": "",
|
||||
"unit": "",
|
||||
},
|
||||
}
|
||||
for _, v := range testData {
|
||||
specQuality, specUnit, unit := SplitProductSpec(v["spec"].(string))
|
||||
// t.Log(specQuality, ",", specUnit, ",", unit)
|
||||
if specQuality != v["specQuality"] {
|
||||
t.Fatalf("%s specQuality is wrong", v["spec"].(string))
|
||||
}
|
||||
if specUnit != v["specUnit"] {
|
||||
t.Fatalf("%s specUnit is wrong", v["spec"].(string))
|
||||
}
|
||||
if unit != v["unit"] {
|
||||
t.Fatalf("%s unit is wrong", v["spec"].(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user