good morning!!!!

Skip to content
Snippets Groups Projects
Commit 6b909cbf authored by a's avatar a
Browse files

recvg

parent fb3bfe7a
Branches
Tags
1 merge request!15Draft: V2
...@@ -40,9 +40,6 @@ func (td *TestData) AddTestData(name string, rd io.Reader) *TestData { ...@@ -40,9 +40,6 @@ func (td *TestData) AddTestData(name string, rd io.Reader) *TestData {
Name: name, Name: name,
} }
td.Files = append(td.Files, t) td.Files = append(td.Files, t)
currentPair := &TestPair{
Request: nil,
}
var ( var (
arrowRight = []byte("-->") arrowRight = []byte("-->")
arrowLeft = []byte("<--") arrowLeft = []byte("<--")
...@@ -58,23 +55,21 @@ func (td *TestData) AddTestData(name string, rd io.Reader) *TestData { ...@@ -58,23 +55,21 @@ func (td *TestData) AddTestData(name string, rd io.Reader) *TestData {
continue continue
} }
if bytes.HasPrefix(txt, arrowRight) { if bytes.HasPrefix(txt, arrowRight) {
if currentPair.Request != nil { currentPair := &TestAction{
t.Pairs = append(t.Pairs, currentPair) Direction: DirectionSend,
}
currentPair = &TestPair{
Request: nil,
} }
currentPair.Request = bytes.TrimSpace(bytes.TrimPrefix(txt, arrowRight)) currentPair.Data = bytes.TrimSpace(bytes.TrimPrefix(txt, arrowRight))
t.Action = append(t.Action, currentPair)
continue continue
} }
if bytes.HasPrefix(txt, arrowLeft) { if bytes.HasPrefix(txt, arrowLeft) {
xs := bytes.TrimSpace(bytes.TrimPrefix(txt, arrowLeft)) currentPair := &TestAction{
currentPair.Responses = append(currentPair.Responses, xs) Direction: DirectionRecv,
continue
} }
currentPair.Data = bytes.TrimSpace(bytes.TrimPrefix(txt, arrowLeft))
t.Action = append(t.Action, currentPair)
continue
} }
if currentPair.Request != nil {
t.Pairs = append(t.Pairs, currentPair)
} }
return nil return nil
} }
...@@ -85,10 +80,17 @@ type TestData struct { ...@@ -85,10 +80,17 @@ type TestData struct {
type TestFile struct { type TestFile struct {
Name string Name string
Pairs []*TestPair Action []*TestAction
} }
type TestPair struct { type TestDirection string
Request json.RawMessage
Responses []json.RawMessage const (
DirectionSend = TestDirection("send")
DirectionRecv = TestDirection("recv")
)
type TestAction struct {
Direction TestDirection
Data json.RawMessage
} }
...@@ -12,11 +12,8 @@ func TestLoadTestData(t *testing.T) { ...@@ -12,11 +12,8 @@ func TestLoadTestData(t *testing.T) {
log.Println(jrpctest.OriginalTestData) log.Println(jrpctest.OriginalTestData)
for _, file := range jrpctest.OriginalTestData.Files { for _, file := range jrpctest.OriginalTestData.Files {
fmt.Printf("file %s:\n", file.Name) fmt.Printf("file %s:\n", file.Name)
for idx, pair := range file.Pairs { for idx, pair := range file.Action {
fmt.Printf(" %d --> %s\n", idx, string(pair.Request)) fmt.Printf(" %d %s %s\n", idx, pair.Direction, string(pair.Data))
for _, v := range pair.Responses {
fmt.Printf(" <-- %s\n", string(v))
}
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment