@@ -18,7 +18,7 @@ func Test_isMatch(t *testing.T) {
1818 tests := []struct {
1919 name string
2020 target ottl.StringLikeGetter [any ]
21- pattern string
21+ pattern ottl. StringGetter [ any ]
2222 expected bool
2323 }{
2424 {
@@ -28,7 +28,11 @@ func Test_isMatch(t *testing.T) {
2828 return "hello world" , nil
2929 },
3030 },
31- pattern : "hello.*" ,
31+ pattern : & ottl.StandardStringGetter [any ]{
32+ Getter : func (_ context.Context , _ any ) (any , error ) {
33+ return "hello.*" , nil
34+ },
35+ },
3236 expected : true ,
3337 },
3438 {
@@ -38,7 +42,11 @@ func Test_isMatch(t *testing.T) {
3842 return "goodbye world" , nil
3943 },
4044 },
41- pattern : "hello.*" ,
45+ pattern : & ottl.StandardStringGetter [any ]{
46+ Getter : func (_ context.Context , _ any ) (any , error ) {
47+ return "hello.*" , nil
48+ },
49+ },
4250 expected : false ,
4351 },
4452 {
@@ -48,7 +56,11 @@ func Test_isMatch(t *testing.T) {
4856 return "-12.001" , nil
4957 },
5058 },
51- pattern : "[-+]?\\ d*\\ .\\ d+([eE][-+]?\\ d+)?" ,
59+ pattern : & ottl.StandardStringGetter [any ]{
60+ Getter : func (_ context.Context , _ any ) (any , error ) {
61+ return "[-+]?\\ d*\\ .\\ d+([eE][-+]?\\ d+)?" , nil
62+ },
63+ },
5264 expected : true ,
5365 },
5466 {
@@ -58,7 +70,11 @@ func Test_isMatch(t *testing.T) {
5870 return true , nil
5971 },
6072 },
61- pattern : "true" ,
73+ pattern : & ottl.StandardStringGetter [any ]{
74+ Getter : func (_ context.Context , _ any ) (any , error ) {
75+ return "true" , nil
76+ },
77+ },
6278 expected : true ,
6379 },
6480 {
@@ -68,7 +84,11 @@ func Test_isMatch(t *testing.T) {
6884 return int64 (1 ), nil
6985 },
7086 },
71- pattern : `\d` ,
87+ pattern : & ottl.StandardStringGetter [any ]{
88+ Getter : func (_ context.Context , _ any ) (any , error ) {
89+ return `\d` , nil
90+ },
91+ },
7292 expected : true ,
7393 },
7494 {
@@ -78,7 +98,11 @@ func Test_isMatch(t *testing.T) {
7898 return 1.1 , nil
7999 },
80100 },
81- pattern : `\d\.\d` ,
101+ pattern : & ottl.StandardStringGetter [any ]{
102+ Getter : func (_ context.Context , _ any ) (any , error ) {
103+ return `\d\.\d` , nil
104+ },
105+ },
82106 expected : true ,
83107 },
84108 {
@@ -90,7 +114,11 @@ func Test_isMatch(t *testing.T) {
90114 return v , nil
91115 },
92116 },
93- pattern : `test` ,
117+ pattern : & ottl.StandardStringGetter [any ]{
118+ Getter : func (_ context.Context , _ any ) (any , error ) {
119+ return `test` , nil
120+ },
121+ },
94122 expected : true ,
95123 },
96124 {
@@ -100,7 +128,11 @@ func Test_isMatch(t *testing.T) {
100128 return nil , nil
101129 },
102130 },
103- pattern : "impossible to match" ,
131+ pattern : & ottl.StandardStringGetter [any ]{
132+ Getter : func (_ context.Context , _ any ) (any , error ) {
133+ return "impossible to match" , nil
134+ },
135+ },
104136 expected : false ,
105137 },
106138 }
@@ -121,7 +153,14 @@ func Test_isMatch_validation(t *testing.T) {
121153 return "anything" , nil
122154 },
123155 }
124- _ , err := isMatch [any ](target , "\\ K" )
156+ invalidRegexPattern := ottl.StandardStringGetter [any ]{
157+ Getter : func (_ context.Context , _ any ) (any , error ) {
158+ return "\\ K" , nil
159+ },
160+ }
161+ exprFunc , err := isMatch [any ](target , invalidRegexPattern )
162+ assert .NoError (t , err )
163+ _ , err = exprFunc (t .Context (), nil )
125164 require .Error (t , err )
126165}
127166
@@ -131,7 +170,12 @@ func Test_isMatch_error(t *testing.T) {
131170 return make (chan int ), nil
132171 },
133172 }
134- exprFunc , err := isMatch [any ](target , "test" )
173+ regexPattern := ottl.StandardStringGetter [any ]{
174+ Getter : func (_ context.Context , _ any ) (any , error ) {
175+ return "test" , nil
176+ },
177+ }
178+ exprFunc , err := isMatch [any ](target , regexPattern )
135179 assert .NoError (t , err )
136180 _ , err = exprFunc (t .Context (), nil )
137181 require .Error (t , err )
0 commit comments