good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
J
jrpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
jrpc
Commits
6b909cbf
Commit
6b909cbf
authored
Jun 8, 2023
by
a
Browse files
Options
Downloads
Patches
Plain Diff
recvg
parent
fb3bfe7a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!15
Draft: V2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/jrpctest/testdata.go
+21
-19
21 additions, 19 deletions
pkg/jrpctest/testdata.go
pkg/jrpctest/testdata_test.go
+2
-5
2 additions, 5 deletions
pkg/jrpctest/testdata_test.go
with
23 additions
and
24 deletions
pkg/jrpctest/testdata.go
+
21
−
19
View file @
6b909cbf
...
@@ -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
[]
*
Test
Pair
Action
[]
*
Test
Action
}
}
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
}
}
This diff is collapsed.
Click to expand it.
pkg/jrpctest/testdata_test.go
+
2
−
5
View file @
6b909cbf
...
@@ -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
))
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment