This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/pkg/alpha.dagger.io/graphql/tests/graphql.cue
Andrea Luzzardi 282759c0e5 cue modules: move stdlib to pkg/alpha.dagger.io
In preparation for Europa, we will vendor multiple CUE modules:

- `pkg/alpha.dagger.io`: legacy non-europa packages
- `pkg/dagger.io`: core Europa packages
- `pkg/universe.dagger.io`: Europa universe

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2022-01-11 13:16:37 -08:00

56 lines
1.1 KiB
CUE

package graphql
import (
"encoding/json"
"alpha.dagger.io/alpine"
"alpha.dagger.io/dagger"
"alpha.dagger.io/docker"
"alpha.dagger.io/os"
"alpha.dagger.io/http"
)
TestDockersocket: dagger.#Stream & dagger.#Input
TestQuery: {
run: docker.#Run & {
name: "graphql-faker"
ref: "apisguru/graphql-faker"
socket: TestDockersocket
ports: ["8080:9002"]
}
// Waits for TestRun to finish initializing
Testhealth: http.#Wait & {
url: "http://localhost:8080/graphql?query={%7BallCompanies%20%7B%0A%20%20%20%20id%0A%20%20%7D%0A%7D}"
}
queryWithoutToken: #Query & {
url: Testhealth.url
query: #"""
{
company(id: "NjExNjAwMjE5Nw==") {
id
}
}
"""#
}
testRaw: os.#Container & {
image: alpine.#Image & {
package: jq: true
}
env: STATUS: "\(queryWithoutToken.post.response.statusCode)"
shell: args: ["--noprofile", "--norc", "-eo", "pipefail", "-c"]
files: "/content.json": {
content: json.Marshal(queryWithoutToken.data)
mode: 0o500
}
command: #"""
test "$STATUS" = "200"
test "$(cat /content.json | jq '.allCompanies | length')" -gt 1
"""#
}
}