github.com/rhatdan/storage@v1.12.13/tests/create-container.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  @test "create-container" {
     6  	# Create a container based on no image.
     7  	run storage --debug=false create-container ""
     8  	[ "$status" -eq 0 ]
     9  	[ "$output" != "" ]
    10  	zerothcontainer=${output%%	*}
    11  
    12  	# Create an image using no layer.
    13  	run storage --debug=false create-image ""
    14  	[ "$status" -eq 0 ]
    15  	[ "$output" != "" ]
    16  	image=${output%%	*}
    17  
    18  	# Create a container based on that image.
    19  	run storage --debug=false create-container $image
    20  	echo "$output"
    21  	[ "$status" -eq 0 ]
    22  	[ "$output" != "" ]
    23  	thirdcontainer=${output%%	*}
    24  
    25  	# Create a layer.
    26  	run storage --debug=false create-layer
    27  	[ "$status" -eq 0 ]
    28  	[ "$output" != "" ]
    29  	layer=$output
    30  
    31  	# Create an image using that layer.
    32  	run storage --debug=false create-image $layer
    33  	[ "$status" -eq 0 ]
    34  	[ "$output" != "" ]
    35  	image=${output%%	*}
    36  
    37  	# Create a container based on that image.
    38  	run storage --debug=false create-container $image
    39  	[ "$status" -eq 0 ]
    40  	[ "$output" != "" ]
    41  	firstcontainer=${output%%	*}
    42  
    43  	firstwriter=$(cat ${TESTDIR}/root/${STORAGE_DRIVER}-containers/containers.lock)
    44  	[ "$firstwriter" != "" ]
    45  
    46  	# Check that the container can be found.
    47  	storage exists -c $firstcontainer
    48  
    49  	# Create another container based on the same image.
    50  	run storage --debug=false create-container $image
    51  	[ "$status" -eq 0 ]
    52  	[ "$output" != "" ]
    53  	secondcontainer=${output%%	*}
    54  
    55  	secondwriter=$(cat ${TESTDIR}/root/${STORAGE_DRIVER}-containers/containers.lock)
    56  	[ "$secondwriter" != "" ]
    57  	[ "$firstwriter" != "$secondwriter" ]
    58  
    59  	# Check that *that* container can be found.
    60  	storage exists -c $secondcontainer
    61  
    62  	# Check that a list of containers lists both of them.
    63  	run storage --debug=false containers
    64  	echo :"$output":
    65  	[ "$status" -eq 0 ]
    66  	[ "${#lines[*]}" -eq 4 ]
    67  	[ "${lines[0]}" != "${lines[1]}" ]
    68  	[ "${lines[0]}" != "${lines[2]}" ]
    69  	[ "${lines[0]}" != "${lines[3]}" ]
    70  	[ "${lines[1]}" != "${lines[2]}" ]
    71  	[ "${lines[1]}" != "${lines[3]}" ]
    72  	[ "${lines[2]}" != "${lines[3]}" ]
    73  	[ "${lines[0]}" = "$zerothcontainer" ] || [ "${lines[0]}" = "$firstcontainer" ] || [ "${lines[0]}" = "$secondcontainer" ] || [ "${lines[0]}" = "$thirdcontainer" ]
    74  	[ "${lines[1]}" = "$zerothcontainer" ] || [ "${lines[1]}" = "$firstcontainer" ] || [ "${lines[1]}" = "$secondcontainer" ] || [ "${lines[1]}" = "$thirdcontainer" ]
    75  	[ "${lines[2]}" = "$zerothcontainer" ] || [ "${lines[2]}" = "$firstcontainer" ] || [ "${lines[2]}" = "$secondcontainer" ] || [ "${lines[2]}" = "$thirdcontainer" ]
    76  	[ "${lines[3]}" = "$zerothcontainer" ] || [ "${lines[3]}" = "$firstcontainer" ] || [ "${lines[3]}" = "$secondcontainer" ] || [ "${lines[3]}" = "$thirdcontainer" ]
    77  }