@@ -7,56 +7,40 @@ load helpers
77
88# Create temporary artifact file for testing
99function create_test_file() {
10- local content=" $1 "
10+ local content=" $( random_string 100 ) "
1111 local filename=$( random_string 12)
1212 local filepath=" $PODMAN_TMPDIR /$filename .txt"
1313 echo " $content " > " $filepath "
1414 echo " $filepath "
1515}
1616
17- function setup() {
18- basic_setup
19- skip_if_remote " artifacts are not remote"
20- }
21-
2217function teardown() {
23- run_podman artifact rm --all --ignore || true
18+ run_podman artifact rm --all --ignore
2419 basic_teardown
2520}
2621
2722@test " podman artifact inspect shows created date in RFC3339 format" {
28- local content=" test content for created date"
29- local testfile1=$( create_test_file " $content " )
23+ local testfile1=$( create_test_file)
3024 local artifact_name=" localhost/test/created-test"
31- local content2=" appended content"
32- local testfile2=$( create_test_file " $content2 " )
25+ local testfile2=$( create_test_file)
3326
34- # Record time before creation (in seconds for comparison)
35- local before_epoch=$( date +%s)
27+ # Record time before creation (in nanoseconds for comparison)
28+ local before_epoch=$( date +%s%N )
3629
3730 # Create artifact
3831 run_podman artifact add $artifact_name " $testfile1 "
3932
40- # Record time after creation (in seconds for comparison)
41- local after_epoch=$( date +%s)
42- after_epoch=$(( after_epoch + 1 ))
33+ # Record time after creation
34+ local after_epoch=$( date +%s%N)
4335
4436 # Inspect the artifact
45- run_podman artifact inspect $artifact_name
46- local output=" $output "
47-
48- # Parse the JSON output to get the created annotation
49- local created_annotation
50- created_annotation=$( echo " $output " | jq -r ' .Manifest.annotations["org.opencontainers.image.created"]' )
51-
52- # Verify created annotation exists and is not null
53- assert " $created_annotation " ! = " null" " Should have org.opencontainers.image.created annotation"
37+ run_podman artifact inspect --format ' {{index .Manifest.Annotations "org.opencontainers.image.created" }}' $artifact_name
38+ local created_annotation=" $output "
5439 assert " $created_annotation " ! = " " " Created annotation should not be empty"
5540
5641 # Verify it's a valid RFC3339 timestamp by trying to parse it
5742 # Convert to epoch for comparison
58- local created_epoch
59- created_epoch=$( date -d " $created_annotation " +%s 2> /dev/null)
43+ local created_epoch=$( date -d " $created_annotation " +%s%N 2> /dev/null)
6044
6145 # Verify parsing succeeded
6246 assert " $? " -eq 0 " Created timestamp should be valid RFC3339 format"
@@ -65,27 +49,19 @@ function teardown() {
6549 assert " $created_epoch " -ge " $before_epoch " " Created time should be after before_epoch"
6650 assert " $created_epoch " -le " $after_epoch " " Created time should be before after_epoch"
6751
68- # Wait a bit to ensure timestamps would differ if created new
69- sleep 1
70-
7152 # Append to artifact
7253 run_podman artifact add --append $artifact_name " $testfile2 "
7354
7455 # Get the created timestamp after append
75- run_podman artifact inspect $artifact_name
76- local current_created
77- current_created= $( echo " $output " | jq -r ' .Manifest.annotations["org.opencontainers.image.created"] ' )
56+ run_podman artifact inspect --format ' {{index .Manifest.Annotations "org.opencontainers.image.created" }}\n{{len .Manifest.Layers}} ' $artifact_name
57+ local current_created= " ${lines[0]} "
58+ local layer_count= " ${lines[1]} "
7859
7960 # Verify the created timestamp is preserved
8061 assert " $current_created " = " $created_annotation " " Created timestamp should be preserved during append"
8162
8263 # Verify we have 2 layers now
83- local layer_count
84- layer_count=$( echo " $output " | jq ' .Manifest.layers | length' )
8564 assert " $layer_count " -eq 2 " Should have 2 layers after append"
86-
87- # Clean up
88- rm -f " $testfile1 " " $testfile2 "
8965}
9066
9167# vim: filetype=sh
0 commit comments