@@ -50,6 +50,20 @@ function teardown() {
5050 sane_run diff -u " $BATS_TMPDIR /a-config.json" " $BATS_TMPDIR /b-config.json"
5151 [ " $status " -eq 0 ]
5252 [ -z " $output " ]
53+
54+ # Make sure that the history was modified.
55+ umoci stat --image " $IMAGE " --tag " $TAG " --json
56+ [ " $status " -eq 0 ]
57+ numLinesA=" $( echo " $output " | jq -SM ' .history | length' ) "
58+
59+ umoci stat --image " $IMAGE " --tag " ${TAG} -new" --json
60+ [ " $status " -eq 0 ]
61+ numLinesB=" $( echo " $output " | jq -SM ' .history | length' ) "
62+
63+ # Number of lines should be greater.
64+ [ " $numLinesB " -gt " $numLinesA " ]
65+ # The final layer should be an empty_layer now.
66+ [[ " $( echo " $output " | jq -SM ' .history[-1].empty_layer' ) " == " true" ]]
5367}
5468
5569@test " umoci config --config.user 'user'" {
@@ -491,23 +505,64 @@ function teardown() {
491505
492506# XXX: This doesn't do any actual testing of the results of any of these flags.
493507# This needs to be fixed after we implement raw-cat or something like that.
494- @test " umoci config --[author+created+history ]" {
508+ @test " umoci config --[author+created]" {
495509 # Modify everything.
496- umoci config --image
" $IMAGE " --from
" $TAG " --tag
" ${TAG} " --author=
" Aleksa Sarai <[email protected] >" --created=
" 2016-03-25T12:34:02.655002+11:00" \
497- --clear=history --history ' {"created_by": "ls -la", "comment": "should work", "author": "me", "empty_layer": false, "created": "2016-03-25T12:34:02.655002+11:00"}' \
498- --history ' {"created_by": "ls -la", "author": "me", "empty_layer": false}'
510+ umoci config --image
" $IMAGE " --from
" $TAG " --tag
" ${TAG} -new" --author=
" Aleksa Sarai <[email protected] >" --created=
" 2016-03-25T12:34:02.655002+11:00" 499511 [ " $status " -eq 0 ]
500512
501- # Make sure that --history doesn't work with a random string.
502- umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} " --history " some random string"
503- [ " $status " -ne 0 ]
504- # FIXME It turns out that Go's JSON parser will ignore unknown keys...
505- # umoci config --image "$IMAGE" --from "$TAG" --tag "${TAG}" --history '{"unknown key": 12, "created_by": "ls -la", "comment": "should not work"}'
506- # [ "$status" -ne 0 ]
507-
508513 # Make sure that --created doesn't work with a random string.
509- umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} " --created=" not a date"
514+ umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} -new " --created=" not a date"
510515 [ " $status " -ne 0 ]
511- umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} " --created=" Jan 04 2004"
516+ umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} -new " --created=" Jan 04 2004"
512517 [ " $status " -ne 0 ]
518+
519+ # Make sure that the history was modified and the author is now me.
520+ umoci stat --image " $IMAGE " --tag " $TAG " --json
521+ [ " $status " -eq 0 ]
522+ numLinesA=" $( echo " $output " | jq -SMr ' .history | length' ) "
523+
524+ umoci stat --image " $IMAGE " --tag " ${TAG} -new" --json
525+ [ " $status " -eq 0 ]
526+ numLinesB=" $( echo " $output " | jq -SMr ' .history | length' ) "
527+
528+ # Number of lines should be greater.
529+ [ " $numLinesB " -gt " $numLinesA " ]
530+ # The final layer should be an empty_layer now.
531+ [[ " $( echo " $output " | jq -SMr ' .history[-1].empty_layer' ) " == " true" ]]
532+ # The author should've changed.
533+ [[
" $( echo " $output " | jq -SMr ' .history[-1].author' ) " == " Aleksa Sarai <[email protected] >" ]]
534+ }
535+
536+ # XXX: We don't do any testing of --author and that the config is changed properly.
537+ @test " umoci config --history.*" {
538+ # Modify something and set the history values.
539+ umoci config --image " $IMAGE " --from " $TAG " --tag " ${TAG} -new" \
540+ --history.author=
" Not Aleksa <[email protected] >" \
541+ --history.comment=" /* Not a real comment. */" \
542+ --history.created_by=" -- <bats> integration test --" \
543+ --history.created=" 2016-12-09T04:45:40+11:00" \
544+ --author=
" Aleksa Sarai <[email protected] >" 545+ [ " $status " -eq 0 ]
546+
547+ # Make sure that the history was modified.
548+ umoci stat --image " $IMAGE " --tag " $TAG " --json
549+ [ " $status " -eq 0 ]
550+ numLinesA=" $( echo " $output " | jq -SMr ' .history | length' ) "
551+
552+ umoci stat --image " $IMAGE " --tag " ${TAG} -new" --json
553+ [ " $status " -eq 0 ]
554+ numLinesB=" $( echo " $output " | jq -SMr ' .history | length' ) "
555+
556+ # Number of lines should be greater.
557+ [ " $numLinesB " -gt " $numLinesA " ]
558+ # The final layer should be an empty_layer now.
559+ [[ " $( echo " $output " | jq -SMr ' .history[-1].empty_layer' ) " == " true" ]]
560+ # The author should've changed to --history.author.
561+ [[
" $( echo " $output " | jq -SMr ' .history[-1].author' ) " == " Not Aleksa <[email protected] >" ]]
562+ # The comment should be added.
563+ [[ " $( echo " $output " | jq -SMr ' .history[-1].comment' ) " == " /* Not a real comment. */" ]]
564+ # The created_by should be set.
565+ [[ " $( echo " $output " | jq -SMr ' .history[-1].created_by' ) " == " -- <bats> integration test --" ]]
566+ # The created should be set.
567+ [[ " $( echo " $output " | jq -SMr ' .history[-1].created' ) " == " 2016-12-09T04:45:40+11:00" ]]
513568}
0 commit comments