| 1 | # SPDX-FileCopyrightText: Copyright The Lima Authors |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | load "../helpers/load" |
| 5 | |
| 6 | @test 'make sure the yq subcommand exists' { |
| 7 | run -0 limactl yq --version |
| 8 | assert_output --regexp '^yq .*mikefarah.* version v' |
| 9 | } |
| 10 | |
| 11 | @test 'yq can evaluate yq expressions' { |
| 12 | run -0 limactl yq -n .foo=42 |
| 13 | assert_output 'foo: 42' |
| 14 | } |
| 15 | |
| 16 | @test 'yq command understand yq options' { |
| 17 | run -0 limactl yq -n -o json -I 0 .foo=42 |
| 18 | assert_output '{"foo":42}' |
| 19 | } |
| 20 | |
| 21 | @test 'yq errors set non-zero exit code' { |
| 22 | run -1 limactl yq -n foo |
| 23 | assert_output --partial "invalid input" |
| 24 | } |
| 25 | |
| 26 | @test 'yq works as a multi-call binary' { |
| 27 | # multi-call command detection strips all extensions |
| 28 | YQ="yq.lima.exe" |
| 29 | ln -sf "$(which limactl)" "${BATS_TEST_TMPDIR}/${YQ}" |
| 30 | export PATH="$BATS_TEST_TMPDIR:$PATH" |
| 31 | |
| 32 | run -0 "$YQ" --version |
| 33 | assert_output --regexp '^yq .*mikefarah.* version v' |
| 34 | |
| 35 | run -0 "$YQ" -n -o json -I 0 .foo=42 |
| 36 | assert_output '{"foo":42}' |
| 37 | } |
| 38 | |
| 39 | @test 'yq multi-call command has support for env access' { |
| 40 | export FOO=bar |
| 41 | run -0 limactl yq -n 'env(FOO)' |
| 42 | assert_output "bar" |
| 43 | } |
| 44 | |
| 45 | @test 'yq multi-call command has support for --security-disable-env-ops' { |
| 46 | export FOO=bar |
| 47 | run_e -1 limactl yq -n --security-disable-env-ops 'env(FOO)' |
| 48 | assert_stderr "Error: env operations have been disabled" |
| 49 | } |
| 50 | |
| 51 | @test 'yq multi-call command has system operations disabled by default' { |
| 52 | run -1 limactl yq -n 'system("echo hello")' |
| 53 | assert_output --partial "system operations are disabled" |
| 54 | } |