@@ -69,8 +69,8 @@ import (
69
69
" fmt"
70
70
" strings"
71
71
72
- " github.com/open-policy-agent/opa/ast"
73
- " github.com/open-policy-agent/opa/topdown/builtins"
72
+ " github.com/open-policy-agent/opa/v1/ ast"
73
+ " github.com/open-policy-agent/opa/v1/ topdown/builtins"
74
74
)
75
75
76
76
// implements topdown.BuiltinFunc
@@ -105,7 +105,7 @@ The call to `RegisterBuiltinFunc(...)` in `init()` adds the built-in function to
105
105
### Test
106
106
107
107
All built-in function implementations must include a test suite.
108
- Test cases for built-in functions are written in YAML and located under ` test/cases/testdata ` .
108
+ Test cases for built-in functions are written in YAML and located under ` test/cases/testdata/v1 ` .
109
109
110
110
We create two new test cases (one positive, expecting a string output; and one negative, expecting an error) for our built-in function:
111
111
@@ -117,7 +117,7 @@ cases:
117
117
- |
118
118
package test
119
119
120
- p := repeated {
120
+ p := repeated if {
121
121
repeated := repeat(input.str, input.count)
122
122
}
123
123
input : {"str": "Foo", "count": 3}
@@ -129,7 +129,7 @@ cases:
129
129
- |
130
130
package test
131
131
132
- p := repeated {
132
+ p := repeated if {
133
133
repeated := repeat(input.str, input.count)
134
134
}
135
135
input : { "str": "Foo", "count": -3 }
@@ -138,7 +138,7 @@ cases:
138
138
want_error : ' repeat: count must be a positive integer'
139
139
` ` `
140
140
141
- The above test cases can be run separate from all other tests through: ` go test ./topdown -v -run 'TestRego/repeat'`
141
+ The above test cases can be run separate from all other tests through: ` go test ./topdown -v -run 'TestRego/v1/ repeat'`
142
142
143
143
See [test/cases/testdata/helloworld](https://github.com/open-policy-agent/opa/blob/main/test/cases/testdata/helloworld)
144
144
for a more detailed example of how to implement tests for your built-in functions.
0 commit comments