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
f0e774a1
Commit
f0e774a1
authored
1 year ago
by
Danis Kirasirov
Browse files
Options
Downloads
Patches
Plain Diff
refactor tests
parent
2a49defe
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
+42
-45
42 additions, 45 deletions
pkg/extension/action_test.go
with
42 additions
and
45 deletions
pkg/extension/action_test.go
+
42
−
45
View file @
f0e774a1
...
...
@@ -8,50 +8,47 @@ import (
"github.com/stretchr/testify/require"
)
func
TestActionCoversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"Protobuf"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Should not lose information"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
action
:=
ActionFromPB
(
pbAction
)
result
:=
ActionToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
t
.
Run
(
"Should return nil if action is nil"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
action
:=
ActionFromPB
(
pbAction
)
result
:=
ActionToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
func
TestActionToProto
(
t
*
testing
.
T
)
{
t
.
Run
(
"Filled struct"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
action
:=
ActionFromPB
(
pbAction
)
result
:=
ActionToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
t
.
Run
(
"Map"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"Should not lose information"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
err
:=
gofakeit
.
Struct
(
&
action
)
require
.
NoError
(
t
,
err
)
dict
:=
ActionToMap
(
action
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
action
,
result
)
})
t
.
Run
(
"Should return zero-value struct if argument is nil"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
dict
:=
ActionToMap
(
action
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
&
Action
{},
result
)
})
t
.
Run
(
"Action is nil"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
Action
action
:=
ActionFromPB
(
pbAction
)
result
:=
ActionToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
}
func
TestActionRequestPBConversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"Should not lose information"
,
func
(
t
*
testing
.
T
)
{
func
TestActionToMap
(
t
*
testing
.
T
)
{
t
.
Run
(
"Filled struct"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
err
:=
gofakeit
.
Struct
(
&
action
)
require
.
NoError
(
t
,
err
)
dict
:=
ActionToMap
(
action
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
action
,
result
)
})
t
.
Run
(
"Action is nil"
,
func
(
t
*
testing
.
T
)
{
var
action
*
Action
dict
:=
ActionToMap
(
action
)
result
,
err
:=
ActionFromMap
(
dict
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
&
Action
{},
result
)
})
}
func
TestActionRequestToProto
(
t
*
testing
.
T
)
{
t
.
Run
(
"Filled struct"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionRequest
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
...
...
@@ -61,7 +58,7 @@ func TestActionRequestPBConversion(t *testing.T) {
require
.
Equal
(
t
,
pbAction
,
result
)
})
t
.
Run
(
"
Should return nil if a
ction is nil"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
A
ction is nil"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionRequest
action
:=
ActionRequestFromPB
(
pbAction
)
result
:=
ActionRequestToPB
(
action
)
...
...
@@ -69,18 +66,18 @@ func TestActionRequestPBConversion(t *testing.T) {
})
}
func
TestActionResponse
PBConversion
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Should not lose information
"
,
func
(
t
*
testing
.
T
)
{
func
TestActionResponse
ToProto
(
t
*
testing
.
T
)
{
t
.
Run
(
"
Filled struct
"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionResponse
err
:=
gofakeit
.
Struct
(
&
pbAction
)
require
.
NoError
(
t
,
err
)
action
:=
ActionResponseFromPB
(
pbAction
)
result
:=
ActionResponseToPB
(
action
)
require
.
Equal
(
t
,
pbAction
,
result
)
})
t
.
Run
(
"
Should return nil if a
ction is nil"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"
A
ction is nil"
,
func
(
t
*
testing
.
T
)
{
var
pbAction
*
pb
.
ActionResponse
action
:=
ActionResponseFromPB
(
pbAction
)
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