正在显示
2 个修改的文件
包含
41 行增加
和
2 行删除
@@ -39,10 +39,10 @@ func GetChanceCode(chanceId int64, chanceTypeId int, templateId int64) (rsp stri | @@ -39,10 +39,10 @@ func GetChanceCode(chanceId int64, chanceTypeId int, templateId int64) (rsp stri | ||
39 | } | 39 | } |
40 | log.Warn(fmt.Sprintf("get chance code retry(%v): cursn:%v cid:%v cc:%v tc:%v", | 40 | log.Warn(fmt.Sprintf("get chance code retry(%v): cursn:%v cid:%v cc:%v tc:%v", |
41 | loopTime, currentSN, chanceId, ChanceTypeCode, TemplateCode)) | 41 | loopTime, currentSN, chanceId, ChanceTypeCode, TemplateCode)) |
42 | - time.Sleep(time.Millisecond * 500) | 42 | + time.Sleep(time.Millisecond * 1000) |
43 | loopTime++ | 43 | loopTime++ |
44 | } | 44 | } |
45 | 45 | ||
46 | - rsp = fmt.Sprintf("%v%v%v", ChanceTypeCode, TemplateCode, Num) | 46 | + rsp = fmt.Sprintf("%v", Num) //fmt.Sprintf("%v%v%v", ChanceTypeCode, TemplateCode, Num) |
47 | return | 47 | return |
48 | } | 48 | } |
services/agg/chance_code_test.go
0 → 100644
1 | +package agg | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "opp/tests" | ||
6 | + "strings" | ||
7 | + "sync" | ||
8 | + "testing" | ||
9 | +) | ||
10 | + | ||
11 | +func Test_GetChanceCode(t *testing.T) { | ||
12 | + tests.Init() | ||
13 | + code, err := GetChanceCode(1, 1, 1) | ||
14 | + if err != nil { | ||
15 | + t.Fatal(err) | ||
16 | + } | ||
17 | + print := func(index int, code string) { | ||
18 | + t.Log(fmt.Sprintf("getChanceCode index:%v code:%v", index, code)) | ||
19 | + } | ||
20 | + print(-1, code) | ||
21 | + | ||
22 | + var wg sync.WaitGroup | ||
23 | + for i := 0; i < 10; i++ { | ||
24 | + wg.Add(1) | ||
25 | + index := i | ||
26 | + go func(in int) { | ||
27 | + defer wg.Done() | ||
28 | + c, e := GetChanceCode(1, 1, 1) | ||
29 | + if e != nil { | ||
30 | + t.Fatal(e) | ||
31 | + } | ||
32 | + if !strings.EqualFold(code, c) { | ||
33 | + t.Fatal("In:", code, "out:", c, "not equal") | ||
34 | + } | ||
35 | + print(in, c) | ||
36 | + }(index) | ||
37 | + } | ||
38 | + wg.Wait() | ||
39 | +} |
-
请 注册 或 登录 后发表评论