Path: blob/dev/pkg/operators/matchers/validate_test.go
2070 views
package matchers12import (3"testing"45"github.com/stretchr/testify/require"6)78func TestValidate(t *testing.T) {9m := &Matcher{matcherType: DSLMatcher, DSL: []string{"anything"}}1011err := m.Validate()12require.Nil(t, err, "Could not validate correct template")1314m = &Matcher{matcherType: DSLMatcher, Part: "test"}15err = m.Validate()16require.NotNil(t, err, "Invalid template was correctly validated")1718m = &Matcher{matcherType: XPathMatcher, XPath: []string{"//q[@id=\"foo\"]"}}1920err = m.Validate()21require.Nil(t, err, "Could not validate correct XPath template")2223m = &Matcher{matcherType: XPathMatcher, Status: []int{123}}24err = m.Validate()25require.NotNil(t, err, "Invalid XPath template was correctly validated")2627m = &Matcher{matcherType: XPathMatcher, XPath: []string{"//a[@a==1]"}}28err = m.Validate()29require.NotNil(t, err, "Invalid XPath query was correctly validated")30}313233