Skip to content
Snippets Groups Projects
Commit f0e774a1 authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

refactor tests

parent 2a49defe
No related branches found
No related tags found
No related merge requests found
......@@ -8,9 +8,8 @@ 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) {
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)
......@@ -20,38 +19,36 @@ func TestActionCoversion(t *testing.T) {
require.Equal(t, pbAction, result)
})
t.Run("Should return nil if action is nil", func(t *testing.T) {
t.Run("Action is nil", func(t *testing.T) {
var pbAction *pb.Action
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) {
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("Should return zero-value struct if argument is nil", func(t *testing.T) {
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 TestActionRequestPBConversion(t *testing.T) {
t.Run("Should not lose information", func(t *testing.T) {
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 action is nil", func(t *testing.T) {
t.Run("Action is nil", func(t *testing.T) {
var pbAction *pb.ActionRequest
action := ActionRequestFromPB(pbAction)
result := ActionRequestToPB(action)
......@@ -69,8 +66,8 @@ func TestActionRequestPBConversion(t *testing.T) {
})
}
func TestActionResponsePBConversion(t *testing.T) {
t.Run("Should not lose information", func(t *testing.T) {
func TestActionResponseToProto(t *testing.T) {
t.Run("Filled struct", func(t *testing.T) {
var pbAction *pb.ActionResponse
err := gofakeit.Struct(&pbAction)
require.NoError(t, err)
......@@ -80,7 +77,7 @@ func TestActionResponsePBConversion(t *testing.T) {
require.Equal(t, pbAction, result)
})
t.Run("Should return nil if action is nil", func(t *testing.T) {
t.Run("Action is nil", func(t *testing.T) {
var pbAction *pb.ActionResponse
action := ActionResponseFromPB(pbAction)
result := ActionResponseToPB(action)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment