forked from opencontainers/runtime-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/t1001-generate-template.t: Add --template tests
Using jq to format the output so we don't have to worry about ocitools' default tab indents or lack of trailing newlines, neither of which play nicely with <<-EOF here documents. The tests are known failures, because runtime-spec v1.0.0-rc1 lacks good omitempty handling. $ ocitools generate --template <(echo '{}') … "hooks": {}, "linux": {}, "solaris": { "cappedCPU": {}, "cappedMemory": {} } } These issues are addressed by the in-flight [1,2], although their late landings in runtime-spec mean we'll never be able to address them in the v1.0.0.rc1 branch of ocitools. [1]: opencontainers/runtime-spec#427 Subject: config: Explicitly list 'hooks' as optional [2]: opencontainers#112 Subject: generate: Adjust to Spec.Linux being a pointer Signed-off-by: W. Trevor King <wking@tremily.us>
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/sh | ||
|
||
test_description='Test generate template' | ||
|
||
. ./sharness.sh | ||
|
||
test_expect_failure CAT,ECHO,HEAD,JQ 'Test ocitools generate --template with an empty template' " | ||
echo '{}' >template && | ||
ocitools generate --template template | jq . >actual && | ||
cat <<-EOF >expected && | ||
{ | ||
\"ociVersion\": \"1.0.0-rc1\", | ||
\"platform\": { | ||
\"os\": \"linux\", | ||
\"arch\": \"amd64\" | ||
}, | ||
\"process\": { | ||
\"user\": { | ||
\"uid\": 0, | ||
\"gid\": 0 | ||
}, | ||
\"args\": null, | ||
\"cwd\": \"/\" | ||
}, | ||
\"root\": { | ||
\"path\": \"rootfs\" | ||
} | ||
} | ||
EOF | ||
test_cmp expected actual | ||
" | ||
|
||
test_expect_failure CAT,HEAD,JQ 'Test ocitools generate --template with a version' " | ||
echo '{\"ociVersion\": \"0.9.0\"}' >template && | ||
ocitools generate --template template | jq . >actual && | ||
cat <<-EOF >expected && | ||
{ | ||
\"ociVersion\": \"0.9.0\", | ||
\"platform\": { | ||
\"os\": \"linux\", | ||
\"arch\": \"amd64\" | ||
}, | ||
\"process\": { | ||
\"user\": { | ||
\"uid\": 0, | ||
\"gid\": 0 | ||
}, | ||
\"args\": null, | ||
\"cwd\": \"/\" | ||
}, | ||
\"root\": { | ||
\"path\": \"rootfs\" | ||
} | ||
} | ||
EOF | ||
test_cmp expected actual | ||
" | ||
|
||
test_done |