github.com/cdoern/storage@v1.12.13/tests/metadata.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  @test "metadata" {
     6  	echo danger > $TESTDIR/danger.txt
     7  
     8  	# Create a layer.
     9  	run storage --debug=false create-layer
    10  	[ "$status" -eq 0 ]
    11  	[ "$output" != "" ]
    12  	layer=$output
    13  
    14  	# Make sure the layer's there.
    15  	storage exists -l $layer
    16  
    17  	# Create an image using the layer and directly-supplied metadata.
    18  	run storage --debug=false create-image -m danger $layer
    19  	[ "$status" -eq 0 ]
    20  	[ "$output" != "" ]
    21  	image=${output%%	*}
    22  
    23  	# Make sure that the image is there.
    24  	storage exists -i $image
    25  
    26  	# Read back the metadata and make sure it's the right value.
    27  	run storage --debug=false metadata -q $image
    28  	[ "$status" -eq 0 ]
    29  	[ "$output" = "danger" ]
    30  
    31  	# Change the metadata to a directly-supplied value.
    32  	run storage set-metadata -m thunder $image
    33  	[ "$status" -eq 0 ]
    34  
    35  	# Read back the metadata and make sure it's the new value.
    36  	run storage --debug=false metadata -q $image
    37  	[ "$status" -eq 0 ]
    38  	[ "$output" = "thunder" ]
    39  
    40  	# Change the metadata to a value supplied via a file.
    41  	storage set-metadata -f $TESTDIR/danger.txt $image
    42  
    43  	# Read back the metadata and make sure it's the newer value.
    44  	run storage --debug=false metadata -q $image
    45  	[ "$status" -eq 0 ]
    46  	[ "$output" = "danger" ]
    47  
    48  	# Create an image using the layer and metadata read from a file.
    49  	run storage --debug=false create-image -f $TESTDIR/danger.txt $layer
    50  	[ "$status" -eq 0 ]
    51  	[ "$output" != "" ]
    52  	image=${output%%	*}
    53  
    54  	# Make sure that the image is there.
    55  	storage exists -i $image
    56  
    57  	# Read back the metadata and make sure it's the right value.
    58  	run storage --debug=false metadata -q $image
    59  	[ "$status" -eq 0 ]
    60  	[ "$output" = "danger" ]
    61  
    62  	# Change the metadata to a directly-supplied value.
    63  	storage set-metadata -m thunder $image
    64  
    65  	# Read back the metadata and make sure it's the new value.
    66  	run storage --debug=false metadata -q $image
    67  	[ "$status" -eq 0 ]
    68  	[ "$output" = "thunder" ]
    69  
    70  	# Change the metadata to a value supplied via a file.
    71  	storage set-metadata -f $TESTDIR/danger.txt $image
    72  
    73  	# Read back the metadata and make sure it's the newer value.
    74  	run storage --debug=false metadata -q $image
    75  	[ "$status" -eq 0 ]
    76  	[ "$output" = "danger" ]
    77  
    78  	# Create a container based on the image and directly-supplied metadata.
    79  	run storage --debug=false create-container -m danger $image
    80  	[ "$status" -eq 0 ]
    81  	[ "$output" != "" ]
    82  	container=${output%%	*}
    83  
    84  	# Make sure the container is there.
    85  	storage exists -c $container
    86  
    87  	# Read the metadata and make sure it's the right value.
    88  	run storage --debug=false metadata -q $container
    89  	[ "$status" -eq 0 ]
    90  	[ "$output" = "danger" ]
    91  
    92  	# Change the metadata to a new value.
    93  	storage set-metadata -m thunder $container
    94  
    95  	# Read back the new metadata value.
    96  	run storage --debug=false metadata -q $container
    97  	[ "$status" -eq 0 ]
    98  	[ "$output" = "thunder" ]
    99  
   100  	# Change the metadata to a new value read from a file.
   101  	storage set-metadata -f $TESTDIR/danger.txt $container
   102  
   103  	# Read back the newer metadata value.
   104  	run storage --debug=false metadata -q $container
   105  	[ "$status" -eq 0 ]
   106  	[ "$output" = "danger" ]
   107  
   108  	# Create a container based on the image and metadata read from a file.
   109  	run storage --debug=false create-container -f $TESTDIR/danger.txt $image
   110  	[ "$status" -eq 0 ]
   111  	[ "$output" != "" ]
   112  	container=${output%%	*}
   113  
   114  	# Make sure the container is there.
   115  	storage exists -c $container
   116  
   117  	# Read the metadata and make sure it's the right value.
   118  	run storage --debug=false metadata -q $container
   119  	[ "$status" -eq 0 ]
   120  	[ "$output" = "danger" ]
   121  
   122  	# Change the metadata to a new value.
   123  	storage set-metadata -m thunder $container
   124  
   125  	# Read back the new metadata value.
   126  	run storage --debug=false metadata -q $container
   127  	[ "$status" -eq 0 ]
   128  	[ "$output" = "thunder" ]
   129  
   130  	# Change the metadata to a new value read from a file.
   131  	storage set-metadata -f $TESTDIR/danger.txt $container
   132  
   133  	# Read back the newer metadata value.
   134  	run storage --debug=false metadata -q $container
   135  	[ "$status" -eq 0 ]
   136  	[ "$output" = "danger" ]
   137  }