From f2e47dd54c13c6ac3e99011f7a4e892eaaf2c150 Mon Sep 17 00:00:00 2001 From: Ilya Date: Tue, 21 Jun 2022 22:35:39 +0100 Subject: [PATCH] Variables test: fix linter Signed-off-by: Ilya --- pkg/runner/test_steps_variables.go | 2 +- pkg/test/param_expander.go | 4 ++-- pkg/test/step.go | 1 + plugins/teststeps/variables/variables_test.go | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/runner/test_steps_variables.go b/pkg/runner/test_steps_variables.go index 31e7049a..a27b5ea0 100644 --- a/pkg/runner/test_steps_variables.go +++ b/pkg/runner/test_steps_variables.go @@ -139,7 +139,7 @@ func (sva *stepVariablesAccessor) Add(tgtID string, name string, in interface{}) } func (sva *stepVariablesAccessor) Get(tgtID string, mappedName string, out interface{}) error { - if sva.varsMapping == nil { + if sva.varsMapping == test.StepVariablesMapping(nil) { return fmt.Errorf("step doesn't have variables mapping") } stepVar, found := sva.varsMapping[mappedName] diff --git a/pkg/test/param_expander.go b/pkg/test/param_expander.go index b2d9d3b9..adbb8aeb 100644 --- a/pkg/test/param_expander.go +++ b/pkg/test/param_expander.go @@ -14,10 +14,10 @@ import ( type ParamExpander struct { t *target.Target - vars StepsVariables + vars StepsVariablesReader } -func NewParamExpander(target *target.Target, vars StepsVariables) *ParamExpander { +func NewParamExpander(target *target.Target, vars StepsVariablesReader) *ParamExpander { return &ParamExpander{t: target, vars: vars} } diff --git a/pkg/test/step.go b/pkg/test/step.go index 7c299de1..560aa2bd 100644 --- a/pkg/test/step.go +++ b/pkg/test/step.go @@ -125,6 +125,7 @@ type StepsVariablesReader interface { // StepsVariables represents a read/write access for step variables type StepsVariables interface { + StepsVariablesReader // Add adds a new or replaces existing variable associated with current test step and target Add(tgtID string, name string, in interface{}) error } diff --git a/plugins/teststeps/variables/variables_test.go b/plugins/teststeps/variables/variables_test.go index 2dfa07b8..96c267a0 100644 --- a/plugins/teststeps/variables/variables_test.go +++ b/plugins/teststeps/variables/variables_test.go @@ -29,7 +29,7 @@ func TestValidateParameters(t *testing.T) { require.NoError(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{ "var1": []test.Param{ { - json.RawMessage("123"), + RawMessage: json.RawMessage("123"), }, }, })) @@ -37,7 +37,7 @@ func TestValidateParameters(t *testing.T) { require.Error(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{ "var var": []test.Param{ { - json.RawMessage("123"), + RawMessage: json.RawMessage("123"), }, }, })) @@ -45,7 +45,7 @@ func TestValidateParameters(t *testing.T) { require.Error(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{ "var1": []test.Param{ { - json.RawMessage("ALALALALA[}"), + RawMessage: json.RawMessage("ALALALALA[}"), }, }, })) @@ -84,17 +84,17 @@ func TestVariablesEmission(t *testing.T) { state, err := obj.Run(ctx, test.TestStepChannels{In: in, Out: out}, ev, svm, test.TestStepParameters{ "str_variable": []test.Param{ { - json.RawMessage("\"dummy\""), + RawMessage: json.RawMessage("\"dummy\""), }, }, "int_variable": []test.Param{ { - json.RawMessage("123"), + RawMessage: json.RawMessage("123"), }, }, "complex_variable": []test.Param{ { - json.RawMessage("{\"name\":\"value\"}"), + RawMessage: json.RawMessage("{\"name\":\"value\"}"), }, }, }, nil)