Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/KurtRudolph/cuelang-testing
A cuelang testing package
https://github.com/KurtRudolph/cuelang-testing
Last synced: 8 days ago
JSON representation
A cuelang testing package
- Host: GitHub
- URL: https://github.com/KurtRudolph/cuelang-testing
- Owner: KurtRudolph
- License: mit
- Created: 2019-11-15T21:01:23.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-04-10T02:21:57.000Z (over 2 years ago)
- Last Synced: 2024-08-12T02:01:49.473Z (3 months ago)
- Size: 28.3 KB
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# testing
**NOTE: Still in early beta and subject to breaking API changes**
A assertion package,
for [cuelang](https://github.com/cuelang/cue).## Usage
Given [`github.com/ipcf/foo/foo.cue`](https://github.com/ipcf/foo/tree/c62ed80729577af59545857dec7f2b3aedb97b89/foo.cue):
```
package fooBar: =~ "^([foo]|[bar])+$"
```one might define tests as follows [`github.com/ipcf/foo/test/foo.cue`](https://github.com/ipcf/foo/tree/c62ed80729577af59545857dec7f2b3aedb97b89/foo.cue):
```
package testimport "github.com/ipcf/testing"
import "github.com/ipcf/foo"
testing.T & {
test: "foo.Bar": {
[testing.NumDot]: subject: foo.Bar
"0": assert: ok: "foo"
"1": assert: notOk: "foobar" // will fail
"2": assert: ok: "bar"
"3": assert: ok: "barfoo"
"4": assert: ok: "barfoo"
"5": assert: ok: "barfoofoobarfoo"
"6": assert: notOk: ""
"7": assert: notOk: "bar1"
"8": assert: notOk: "1bar"
"9": assert: notOk: int
"10": assert: notOk: null
"11": assert: notOk: {}
}
}
```and then evaluate package in the `test/` directory:
```
foo/test [master] » cue eval
test: {
BarBaz: {
"0": {
subject: =~"^([foo]|[bar])+$"
assert: {
ok: "foo"
pass: true
}
}
"1": {
subject: =~"^([foo]|[bar])+$"
.
.
.
```Kind of a lot of output so let's just look at failed tests:
```
foo/test [master] » cue eval --expression FAIL
BarBaz: {
"1": {
subject: =~"^([foo]|[bar])+$"
assert: {
pass: false
notOk: "foobar"
}
}
}
```
Looks like `BarBaz: "1": notOk: "foobar"` failed :+1## LICENSE
MIT License, see [LICENSE](LICENSE)