-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_testcase_test.go
46 lines (39 loc) · 1.11 KB
/
process_testcase_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package venom
import (
"context"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)
func TestProcessVariableAssignments(t *testing.T) {
InitTestLogger(t)
assign := AssignStep{}
assign.Assignments = make(map[string]Assignment)
assign.Assignments["assignVar"] = Assignment{
From: "here.some.value",
}
assign.Assignments["assignVarWithRegex"] = Assignment{
From: "here.some.value",
Regex: `this is (?s:(.*))`,
}
b, _ := yaml.Marshal(assign)
t.Log("\n" + string(b))
tcVars := H{"here.some.value": "this is the \nvalue"}
result, is, err := processVariableAssignments(context.TODO(), "", tcVars, b)
assert.True(t, is)
assert.NoError(t, err)
assert.NotNil(t, result)
t.Log(result)
assert.Equal(t, "map[assignVar:this is the \nvalue assignVarWithRegex:the \nvalue]", fmt.Sprint(result))
var wrongStepIn TestStep
b = []byte(`type: exec
script: echo 'foo'
`)
assert.NoError(t, yaml.Unmarshal(b, &wrongStepIn))
result, is, err = processVariableAssignments(context.TODO(), "", tcVars, b)
assert.False(t, is)
assert.NoError(t, err)
assert.Nil(t, result)
assert.Empty(t, result)
}