Skip to content

Commit

Permalink
Variables test: fix linter
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya <[email protected]>
  • Loading branch information
rihter007 committed Jun 27, 2022
1 parent ffcd62e commit f2e47dd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/runner/test_steps_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions pkg/test/param_expander.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/test/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions plugins/teststeps/variables/variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ func TestValidateParameters(t *testing.T) {
require.NoError(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{
"var1": []test.Param{
{
json.RawMessage("123"),
RawMessage: json.RawMessage("123"),
},
},
}))
// invalid variable name
require.Error(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{
"var var": []test.Param{
{
json.RawMessage("123"),
RawMessage: json.RawMessage("123"),
},
},
}))
// invalid value
require.Error(t, obj.ValidateParameters(xcontext.Background(), test.TestStepParameters{
"var1": []test.Param{
{
json.RawMessage("ALALALALA[}"),
RawMessage: json.RawMessage("ALALALALA[}"),
},
},
}))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f2e47dd

Please sign in to comment.