| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | #!/usr/bin/env bats | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | load helpers | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @test "from" { | 
					
						
							| 
									
										
										
										
											2019-12-09 21:45:52 +08:00
										 |  |  |   _prefetch alpine | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json --name i-love-naming-things alpine | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm i-love-naming-things | 
					
						
							| 
									
										
										
										
											2017-03-18 05:46:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @test "from-defaultpull" { | 
					
						
							| 
									
										
										
										
											2019-12-09 21:45:52 +08:00
										 |  |  |   _prefetch alpine | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json alpine | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2017-03-18 05:46:21 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-29 05:38:15 +08:00
										 |  |  | @test "from-scratch" { | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --pull=true  --signature-policy ${TESTSDIR}/policy.json scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2017-03-29 05:38:15 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-18 05:46:21 +08:00
										 |  |  | @test "from-nopull" { | 
					
						
							| 
									
										
										
										
											2020-04-16 21:48:43 +08:00
										 |  |  |   run_buildah 125 from --pull-never --signature-policy ${TESTSDIR}/policy.json alpine | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @test "mount" { | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							|  |  |  |   run_buildah mount $cid | 
					
						
							|  |  |  |   root=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah unmount $cid | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah mount $cid | 
					
						
							|  |  |  |   root=$output | 
					
						
							| 
									
										
										
										
											2017-03-28 02:46:35 +08:00
										 |  |  |   touch $root/foobar | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah unmount $cid | 
					
						
							|  |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-16 05:25:05 +08:00
										 |  |  | @test "by-name" { | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --signature-policy ${TESTSDIR}/policy.json --name scratch-working-image-for-test scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							|  |  |  |   run_buildah mount scratch-working-image-for-test | 
					
						
							|  |  |  |   root=$output | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah unmount scratch-working-image-for-test | 
					
						
							|  |  |  |   run_buildah rm scratch-working-image-for-test | 
					
						
							| 
									
										
										
										
											2017-03-16 05:25:05 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | @test "commit" { | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   createrandom ${TESTDIR}/randomfile | 
					
						
							|  |  |  |   createrandom ${TESTDIR}/other-randomfile | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch | 
					
						
							|  |  |  |   cid=$output | 
					
						
							|  |  |  |   run_buildah mount $cid | 
					
						
							|  |  |  |   root=$output | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   cp ${TESTDIR}/randomfile $root/randomfile | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah unmount $cid | 
					
						
							|  |  |  |   run_buildah commit --iidfile output.iid --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image | 
					
						
							| 
									
										
										
										
											2018-04-25 22:00:46 +08:00
										 |  |  |   iid=$(cat output.iid) | 
					
						
							| 
									
										
										
										
											2021-02-08 18:59:39 +08:00
										 |  |  |   [[ "$iid" == "sha256:"* ]] | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rmi $iid | 
					
						
							|  |  |  |   run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image | 
					
						
							|  |  |  |   run_buildah rm $cid | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json new-image | 
					
						
							|  |  |  |   newcid=$output | 
					
						
							|  |  |  |   run_buildah mount $newcid | 
					
						
							|  |  |  |   newroot=$output | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   test -s $newroot/randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/randomfile $newroot/randomfile | 
					
						
							|  |  |  |   cp ${TESTDIR}/other-randomfile $newroot/other-randomfile | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:other-new-image | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   # Not an allowed ordering of arguments and flags.  Check that it's rejected. | 
					
						
							| 
									
										
										
										
											2020-04-16 21:48:43 +08:00
										 |  |  |   run_buildah 125 commit $newcid --signature-policy ${TESTSDIR}/policy.json containers-storage:rejected-new-image | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:another-new-image | 
					
						
							|  |  |  |   run_buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid yet-another-new-image | 
					
						
							|  |  |  |   run_buildah commit --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:gratuitous-new-image | 
					
						
							|  |  |  |   run_buildah unmount $newcid | 
					
						
							|  |  |  |   run_buildah rm $newcid | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json other-new-image | 
					
						
							|  |  |  |   othernewcid=$output | 
					
						
							|  |  |  |   run_buildah mount $othernewcid | 
					
						
							|  |  |  |   othernewroot=$output | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   test -s $othernewroot/randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/randomfile $othernewroot/randomfile | 
					
						
							|  |  |  |   test -s $othernewroot/other-randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/other-randomfile $othernewroot/other-randomfile | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $othernewcid | 
					
						
							| 
									
										
										
										
											2017-03-18 05:46:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json another-new-image | 
					
						
							|  |  |  |   anothernewcid=$output | 
					
						
							|  |  |  |   run_buildah mount $anothernewcid | 
					
						
							|  |  |  |   anothernewroot=$output | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   test -s $anothernewroot/randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/randomfile $anothernewroot/randomfile | 
					
						
							|  |  |  |   test -s $anothernewroot/other-randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/other-randomfile $anothernewroot/other-randomfile | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rm $anothernewcid | 
					
						
							| 
									
										
										
										
											2017-03-18 05:46:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json yet-another-new-image | 
					
						
							|  |  |  |   yetanothernewcid=$output | 
					
						
							|  |  |  |   run_buildah mount $yetanothernewcid | 
					
						
							|  |  |  |   yetanothernewroot=$output | 
					
						
							| 
									
										
										
										
											2017-03-25 00:49:22 +08:00
										 |  |  |   test -s $yetanothernewroot/randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/randomfile $yetanothernewroot/randomfile | 
					
						
							|  |  |  |   test -s $yetanothernewroot/other-randomfile | 
					
						
							|  |  |  |   cmp ${TESTDIR}/other-randomfile $yetanothernewroot/other-randomfile | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah delete $yetanothernewcid | 
					
						
							| 
									
										
										
										
											2017-03-29 05:08:37 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-12 03:11:08 +08:00
										 |  |  |   run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json new-image | 
					
						
							|  |  |  |   newcid=$output | 
					
						
							| 
									
										
										
										
											2019-12-12 04:03:37 +08:00
										 |  |  |   run_buildah commit --rm --signature-policy ${TESTSDIR}/policy.json $newcid containers-storage:remove-container-image | 
					
						
							| 
									
										
										
										
											2020-04-16 21:48:43 +08:00
										 |  |  |   run_buildah 125 mount $newcid | 
					
						
							| 
									
										
										
										
											2017-07-14 20:57:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rmi remove-container-image | 
					
						
							|  |  |  |   run_buildah rmi containers-storage:other-new-image | 
					
						
							|  |  |  |   run_buildah rmi another-new-image | 
					
						
							| 
									
										
										
										
											2019-12-12 02:28:27 +08:00
										 |  |  |   run_buildah images -q | 
					
						
							| 
									
										
										
										
											2017-03-29 05:08:37 +08:00
										 |  |  |   [ "$output" != "" ] | 
					
						
							| 
									
										
										
										
											2019-04-02 05:56:29 +08:00
										 |  |  |   run_buildah rmi -a | 
					
						
							| 
									
										
										
										
											2019-12-12 02:28:27 +08:00
										 |  |  |   run_buildah images -q | 
					
						
							| 
									
										
										
										
											2019-04-05 23:59:54 +08:00
										 |  |  |   expect_output "" | 
					
						
							| 
									
										
										
										
											2017-03-07 07:11:40 +08:00
										 |  |  | } |