2021-04-02 03:46:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit -o errtrace -o functrace -o nounset -o pipefail
|
|
|
|
|
|
|
|
# Test Directory
|
|
|
|
d=$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)
|
|
|
|
|
|
|
|
test::cli() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
test::cli::list "$dagger"
|
|
|
|
test::cli::newdir "$dagger"
|
2021-04-02 22:55:01 +02:00
|
|
|
test::cli::newgit "$dagger"
|
2021-04-02 03:46:08 +02:00
|
|
|
test::cli::query "$dagger"
|
2021-04-03 00:02:14 +02:00
|
|
|
test::cli::plan "$dagger"
|
2021-04-03 01:40:41 +02:00
|
|
|
test::cli::input "$dagger"
|
2021-04-02 03:46:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
test::cli::list() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
|
|
|
test::one "CLI: list: no deployments" --stdout="" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" list
|
|
|
|
|
|
|
|
test::one "CLI: list: create deployment" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
|
|
|
|
|
|
|
|
test::one "CLI: list: with deployments" --stdout="simple" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" list
|
|
|
|
}
|
|
|
|
|
|
|
|
test::cli::newdir() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
|
|
|
test::one "CLI: new: --plan-dir" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
|
|
|
|
|
|
|
|
test::one "CLI: new: duplicate name" --exit=1 \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
|
|
|
|
|
|
|
|
test::one "CLI: new: verify plan can be upped" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple"
|
|
|
|
|
|
|
|
test::one "CLI: new: verify we have the right plan" --stdout='{
|
2021-04-09 03:31:10 +02:00
|
|
|
"bar": "another value",
|
|
|
|
"computed": "test",
|
|
|
|
"foo": "value"
|
2021-04-02 03:46:08 +02:00
|
|
|
}' \
|
2021-04-09 03:31:10 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c -f json
|
2021-04-02 03:46:08 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 22:55:01 +02:00
|
|
|
test::cli::newgit() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: new git: --plan-git" \
|
2021-04-02 22:55:01 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-git https://github.com/samalba/dagger-test.git simple
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: new git: verify plan can be upped" \
|
2021-04-02 22:55:01 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple"
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: new git: verify we have the right plan" --stdout='{
|
2021-04-02 22:55:01 +02:00
|
|
|
foo: "value"
|
|
|
|
bar: "another value"
|
|
|
|
}' \
|
2021-04-03 02:16:57 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -f cue -d "simple" -c
|
2021-04-02 22:55:01 +02:00
|
|
|
}
|
|
|
|
|
2021-04-02 03:46:08 +02:00
|
|
|
test::cli::query() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
|
|
|
test::one "CLI: query: initialize simple" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
|
|
|
|
|
2021-04-09 03:31:10 +02:00
|
|
|
test::one "CLI: query: before up" --stdout='{
|
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
2021-04-02 03:46:08 +02:00
|
|
|
}' \
|
2021-04-09 03:31:10 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple"
|
|
|
|
|
|
|
|
test::one "CLI: query: concrete should fail" --exit=1 \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
|
2021-04-02 03:46:08 +02:00
|
|
|
|
|
|
|
test::one "CLI: query: target" --stdout='"value"' \
|
2021-04-09 03:31:10 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" foo
|
2021-04-02 03:46:08 +02:00
|
|
|
|
2021-04-09 03:31:10 +02:00
|
|
|
test::one "CLI: query: compute missing values" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple"
|
|
|
|
|
|
|
|
test::one "CLI: query: all values" --stdout='{
|
|
|
|
"bar": "another value",
|
|
|
|
"computed": "test",
|
|
|
|
"foo": "value"
|
|
|
|
}' \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple"
|
2021-04-02 03:46:08 +02:00
|
|
|
|
2021-04-09 03:31:10 +02:00
|
|
|
test::one "CLI: query: concrete should work" --stdout='{
|
|
|
|
"bar": "another value",
|
|
|
|
"computed": "test",
|
|
|
|
"foo": "value"
|
|
|
|
}' \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
|
|
|
|
|
|
|
|
test::one "CLI: query --no-computed" --stdout='{
|
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
|
|
|
}' \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" --no-computed
|
|
|
|
|
|
|
|
test::one "CLI: query: --no-plan" --stdout='{
|
|
|
|
"computed": "test"
|
|
|
|
}' \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c --no-plan
|
2021-04-02 03:46:08 +02:00
|
|
|
}
|
2021-04-03 00:02:14 +02:00
|
|
|
|
|
|
|
test::cli::plan() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
|
|
|
test::one "CLI: new" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple
|
|
|
|
|
|
|
|
test::one "CLI: plan dir" \
|
2021-04-09 03:31:10 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan dir "$d"/cli/simple
|
2021-04-03 00:02:14 +02:00
|
|
|
|
2021-04-09 03:31:10 +02:00
|
|
|
test::one "CLI: plan dir: verify we have the right plan" --stdout='{
|
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
|
|
|
}' \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" query
|
2021-04-03 00:02:14 +02:00
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: plan git" \
|
2021-04-03 00:02:14 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" -d "simple" plan git https://github.com/samalba/dagger-test.git
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: plan git: verify we have the right plan" --stdout='{
|
2021-04-09 03:31:10 +02:00
|
|
|
"bar": "another value",
|
|
|
|
"foo": "value"
|
2021-04-03 00:02:14 +02:00
|
|
|
}' \
|
2021-04-09 03:31:10 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c
|
2021-04-03 00:02:14 +02:00
|
|
|
}
|
2021-04-03 01:40:41 +02:00
|
|
|
|
|
|
|
test::cli::input() {
|
|
|
|
local dagger="$1"
|
|
|
|
|
|
|
|
# Create temporary store
|
|
|
|
local DAGGER_STORE
|
|
|
|
DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)"
|
|
|
|
export DAGGER_STORE
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: new" \
|
2021-04-03 01:40:41 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/input "input"
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: up missing input" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input"
|
2021-04-03 01:40:41 +02:00
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: query missing input" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "input" --stdout='{
|
|
|
|
"foo": "bar"
|
|
|
|
}'
|
|
|
|
|
|
|
|
test::one "CLI: input: set dir" \
|
2021-04-03 01:40:41 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" input -d "input" dir "source" ./tests/cli/input/testdata
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: up with input dir" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input"
|
|
|
|
|
|
|
|
test::one "CLI: input: query with input dir" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "input" --stdout='{
|
|
|
|
"bar": "thisisatest\n",
|
|
|
|
"foo": "bar",
|
|
|
|
"source": {}
|
|
|
|
}'
|
2021-04-03 01:40:41 +02:00
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: set git" \
|
2021-04-03 01:40:41 +02:00
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" input -d "input" git "source" https://github.com/samalba/dagger-test-simple.git
|
|
|
|
|
2021-04-09 02:22:34 +02:00
|
|
|
test::one "CLI: input: up with input git" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "input"
|
|
|
|
|
|
|
|
test::one "CLI: query with input git" \
|
|
|
|
"$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "input" --stdout='{
|
|
|
|
"bar": "testgit\n",
|
|
|
|
"foo": "bar",
|
|
|
|
"source": {}
|
|
|
|
}'
|
2021-04-03 01:40:41 +02:00
|
|
|
}
|