Skip to content

Commit

Permalink
test/t1001-generate-template.t: Add --template tests
Browse files Browse the repository at this point in the history
Using jq to format the output so we don't have to worry about
oci-runtime-tool's default tab indents or lack of trailing newlines,
neither of which play nicely with <<-EOF here documents.

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed Jul 19, 2017
1 parent 0bb1469 commit bce36c1
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ And read the `Makefile` source to find other useful targets

* [GNU Core Utilities][coreutils] for [`cat`][cat.1],
[`echo`][echo.1], [`head`][head.1], and [`sed][sed.1].
* [jq] for [`jq`][jq.1].

[coreutils]: http://www.gnu.org/software/coreutils/coreutils.html
[jq]: https://stedolan.github.io/jq/
[prove]: http://perldoc.perl.org/prove.html
[Sharness]: http://mlafeldt.github.io/sharness/
[submodule]: http://git-scm.com/docs/git-submodule

[cat.1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cat.html
[echo.1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
[head.1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html
[jq.1]: https://stedolan.github.io/jq/manual/
[sed.1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html
3 changes: 3 additions & 0 deletions test/sharness.d/miscellaneous.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
command -v jq >/dev/null 2>/dev/null && test_set_prereq JQ

true
51 changes: 51 additions & 0 deletions test/t1001-generate-template.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

test_description='Test generate template'

. ./sharness.sh

test_expect_success CAT,ECHO,HEAD,JQ 'Test oci-runtime-tool generate --template with an empty template' "
echo '{}' >template &&
oci-runtime-tool generate --template template | jq . >actual &&
cat <<-EOF >expected &&
{
\"ociVersion\": \"1.0.0-rc6\",
\"process\": {
\"user\": {
\"uid\": 0,
\"gid\": 0
},
\"args\": null,
\"cwd\": \"/\"
},
\"root\": {
\"path\": \"rootfs\"
}
}
EOF
test_cmp expected actual
"

test_expect_success CAT,HEAD,JQ 'Test oci-runtime-tool generate --template with a different version' "
echo '{\"ociVersion\": \"1.0.0-rc9\"}' >template &&
oci-runtime-tool generate --template template | jq . >actual &&
cat <<-EOF >expected &&
{
\"ociVersion\": \"1.0.0-rc9\",
\"process\": {
\"user\": {
\"uid\": 0,
\"gid\": 0
},
\"args\": null,
\"cwd\": \"/\"
},
\"root\": {
\"path\": \"rootfs\"
}
}
EOF
test_cmp expected actual
"

test_done

0 comments on commit bce36c1

Please sign in to comment.