2021-10-07 01:40:49 +05:30
|
|
|
package expressions
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestUnresolvedVariablesCheck(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
data string
|
|
|
|
|
err error
|
|
|
|
|
}{
|
|
|
|
|
{"{{test}}", errors.New("unresolved variables found: test")},
|
|
|
|
|
{"{{test}}/{{another}}", errors.New("unresolved variables found: test,another")},
|
|
|
|
|
{"test", nil},
|
2021-10-07 05:35:32 +05:30
|
|
|
{"%7b%7btest%7d%7d", errors.New("unresolved variables found: test")},
|
2022-11-01 20:28:50 +05:30
|
|
|
{"%7B%7Bfirst%2Asecond%7D%7D", errors.New("unresolved variables found: first%2Asecond")},
|
2022-02-28 22:19:51 +05:30
|
|
|
{"{{7*7}}", nil},
|
2022-06-13 10:25:06 +02:00
|
|
|
{"{{'a'+'b'}}", nil},
|
|
|
|
|
{"{{'a'}}", nil},
|
2021-10-07 01:40:49 +05:30
|
|
|
}
|
|
|
|
|
for _, test := range tests {
|
|
|
|
|
err := ContainsUnresolvedVariables(test.data)
|
|
|
|
|
require.Equal(t, test.err, err, "could not get unresolved variables")
|
|
|
|
|
}
|
|
|
|
|
}
|