forked from crossoverJie/ptg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed3056f
commit bb46e7e
Showing
6 changed files
with
143 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/crossoverJie/ptg/gui/io" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestHistory_Search(t *testing.T) { | ||
history := NewHistory(10, nil, nil, nil, nil, nil) | ||
history.Put(1, &HistoryValue{ | ||
Id: 1, | ||
Value: &io.Log{ | ||
Target: "127.0.0.1:6001", | ||
Request: "{\"order_id\":0,\"reason_id\":null,\"remark\":\"\",\"user_id\":null}", | ||
Metadata: "{\"name\":\"abc\"}", | ||
Response: "", | ||
}, | ||
MethodInfo: "order.v1.OrderService.Create", | ||
}) | ||
history.Put(2, &HistoryValue{ | ||
Id: 2, | ||
Value: &io.Log{ | ||
Target: "127.0.0.1:6002", | ||
Request: "{\"order_id\":99999,\"reason_id\":null,\"remark\":\"\",\"user_id\":null}", | ||
Metadata: "{\"name\":\"zhangsan\"}", | ||
Response: "", | ||
}, | ||
MethodInfo: "order.v1.OrderService.Close", | ||
}) | ||
history.Put(3, &HistoryValue{ | ||
Id: 3, | ||
Value: &io.Log{ | ||
Target: "127.0.0.1:6003", | ||
Request: "{\"order_id\":99999,\"reason_id\":null,\"remark\":\"\",\"user_id\":null}", | ||
Metadata: "{\"name\":\"zhangsan\"}", | ||
Response: "", | ||
}, | ||
MethodInfo: "order.v1.OrderService.List", | ||
}) | ||
|
||
search := history.SearchResult("6001") | ||
for _, value := range search { | ||
marshal, _ := json.Marshal(value) | ||
fmt.Println(string(marshal)) | ||
assert.Equal(t, value.Id, 1) | ||
} | ||
search = history.SearchResult("9999") | ||
for _, value := range search { | ||
marshal, _ := json.Marshal(value) | ||
fmt.Println(string(marshal)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters