Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-go
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-go
Commits
2a49defe
Commit
2a49defe
authored
1 year ago
by
Danis Kirasirov
Browse files
Options
Downloads
Patches
Plain Diff
refactor tests
parent
e9bf9b7b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/extension/action_test.go
+41
-37
41 additions, 37 deletions
pkg/extension/action_test.go
with
41 additions
and
37 deletions
pkg/extension/action_test.go
+
41
−
37
View file @
2a49defe
...
@@ -8,46 +8,50 @@ import (
...
@@ -8,46 +8,50 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
func
TestAction
(
t
*
testing
.
T
)
{
func
TestAction
Coversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"Protobuf"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Protobuf"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
t
.
Run
(
"Should not lose information"
,
func
(
t
*
testing
.
T
)
{
err
:=
gofakeit
.
Struct
(
&
pbAction
)
var
pbAction
*
pb
.
Action
require
.
NoError
(
t
,
err
)
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
action
:=
ActionFromPB
(
pbAction
)
result
:=
ActionToPB
(
action
)
action
:=
ActionFromPB
(
pbAction
)
require
.
Equal
(
t
,
pbAction
,
result
)
result
:=
ActionToPB
(
action
)
})
require
.
Equal
(
t
,
pbAction
,
result
)
})
t
.
Run
(
"Nil Protobuf"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
t
.
Run
(
"Should return nil if action is nil"
,
func
(
t
*
testing
.
T
)
{
action
:=
ActionFromPB
(
pbAction
)
var
pbAction
*
pb
.
Action
result
:=
ActionToPB
(
action
)
action
:=
ActionFromPB
(
pbAction
)
require
.
Equal
(
t
,
pbAction
,
result
)
result
:=
ActionToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
})
})
t
.
Run
(
"Map"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Map"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
t
.
Run
(
"Should not lose information"
,
func
(
t
*
testing
.
T
)
{
err
:=
gofakeit
.
Struct
(
&
action
)
var
action
*
Action
require
.
NoError
(
t
,
err
)
err
:=
gofakeit
.
Struct
(
&
action
)
require
.
NoError
(
t
,
err
)
dict
:=
ActionToMap
(
action
)
result
,
err
:=
ActionFromMap
(
dict
)
dict
:=
ActionToMap
(
action
)
require
.
NoError
(
t
,
err
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
Equal
(
t
,
action
,
result
)
require
.
NoError
(
t
,
err
)
})
require
.
Equal
(
t
,
action
,
result
)
})
t
.
Run
(
"Nil Map"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
t
.
Run
(
"Should return zero-value struct if argument is nil"
,
func
(
t
*
testing
.
T
)
{
dict
:=
ActionToMap
(
action
)
var
action
*
Action
result
,
err
:=
ActionFromMap
(
dict
)
dict
:=
ActionToMap
(
action
)
require
.
NoError
(
t
,
err
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
Equal
(
t
,
&
Action
{},
result
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
&
Action
{},
result
)
})
})
})
}
}
func
TestActionRequest
(
t
*
testing
.
T
)
{
func
TestActionRequest
PBConversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Protobuf
"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Should not lose information
"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionRequest
var
pbAction
*
pb
.
ActionRequest
err
:=
gofakeit
.
Struct
(
&
pbAction
)
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -57,7 +61,7 @@ func TestActionRequest(t *testing.T) {
...
@@ -57,7 +61,7 @@ func TestActionRequest(t *testing.T) {
require
.
Equal
(
t
,
pbAction
,
result
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
})
t
.
Run
(
"
N
il"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Should return nil if action is n
il"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionRequest
var
pbAction
*
pb
.
ActionRequest
action
:=
ActionRequestFromPB
(
pbAction
)
action
:=
ActionRequestFromPB
(
pbAction
)
result
:=
ActionRequestToPB
(
action
)
result
:=
ActionRequestToPB
(
action
)
...
@@ -65,8 +69,8 @@ func TestActionRequest(t *testing.T) {
...
@@ -65,8 +69,8 @@ func TestActionRequest(t *testing.T) {
})
})
}
}
func
TestActionResponse
(
t
*
testing
.
T
)
{
func
TestActionResponse
PBConversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Protobuf
"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Should not lose information
"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionResponse
var
pbAction
*
pb
.
ActionResponse
err
:=
gofakeit
.
Struct
(
&
pbAction
)
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -76,7 +80,7 @@ func TestActionResponse(t *testing.T) {
...
@@ -76,7 +80,7 @@ func TestActionResponse(t *testing.T) {
require
.
Equal
(
t
,
pbAction
,
result
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
})
t
.
Run
(
"
N
il"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Should return nil if action is n
il"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionResponse
var
pbAction
*
pb
.
ActionResponse
action
:=
ActionResponseFromPB
(
pbAction
)
action
:=
ActionResponseFromPB
(
pbAction
)
result
:=
ActionResponseToPB
(
action
)
result
:=
ActionResponseToPB
(
action
)
...
...
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