Skip to content

Commit ad7a735

Browse files
doc: update builtin function examples for v1 (#7514)
Signed-off-by: Rob Myers <[email protected]>
1 parent cc0e87d commit ad7a735

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: docs/content/contrib-adding-builtin-functions.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ import (
6969
"fmt"
7070
"strings"
7171

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"
7474
)
7575

7676
// implements topdown.BuiltinFunc
@@ -105,7 +105,7 @@ The call to `RegisterBuiltinFunc(...)` in `init()` adds the built-in function to
105105
### Test
106106

107107
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`.
109109

110110
We create two new test cases (one positive, expecting a string output; and one negative, expecting an error) for our built-in function:
111111

@@ -117,7 +117,7 @@ cases:
117117
- |
118118
package test
119119
120-
p := repeated {
120+
p := repeated if {
121121
repeated := repeat(input.str, input.count)
122122
}
123123
input: {"str": "Foo", "count": 3}
@@ -129,7 +129,7 @@ cases:
129129
- |
130130
package test
131131
132-
p := repeated {
132+
p := repeated if {
133133
repeated := repeat(input.str, input.count)
134134
}
135135
input: { "str": "Foo", "count": -3 }
@@ -138,7 +138,7 @@ cases:
138138
want_error: 'repeat: count must be a positive integer'
139139
```
140140
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'`
142142

143143
See [test/cases/testdata/helloworld](https://github.com/open-policy-agent/opa/blob/main/test/cases/testdata/helloworld)
144144
for a more detailed example of how to implement tests for your built-in functions.

0 commit comments

Comments
 (0)