Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Mar 19, 2024
1 parent c5b32f6 commit 3bca5d7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
10 changes: 9 additions & 1 deletion apt/private/dpkg_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ shift 2

tmp_out=$(mktemp)

echo "1"

while (( $# > 0 )); do
control="$($bsdtar -xf "$1" --to-stdout ./control)"
echo "$control" | head -n 1 >> $tmp_out
Expand All @@ -16,7 +18,13 @@ while (( $# > 0 )); do
shift
done

echo "2"

mtree_out=$(mktemp)
echo "#mtree
./var/lib/dpkg/status type=file uid=0 gid=0 mode=0644 contents=$tmp_out
" | "$bsdtar" $@ -cf "$out" @-
" > $mtree_out
echo "3"
"$bsdtar" $@ -cf "$out" "@$mtree_out"

rm $tmp_out $mtree_out
5 changes: 4 additions & 1 deletion examples/apt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ oci_tarball(

container_structure_test(
name = "test",
configs = ["test.yaml"],
configs = select({
"@platforms//cpu:arm64": ["test_linux_arm64.yaml"],
"@platforms//cpu:x86_64": ["test_linux_amd64.yaml"],
}),
image = ":apt",
)
23 changes: 23 additions & 0 deletions examples/apt/test_linux_amd64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schemaVersion: "2.0.0"

commandTests:
- name: "echo hello"
command: "/bin/bash"
args: ["-c", "echo hello world!"]
expectedOutput: ["hello world!"]
- name: "apt list --installed"
command: "apt"
args: ["list", "--installed"]
expectedOutput:
- Listing\.\.\.
- apt/now 2\.2\.4 amd64 \[installed,local\]
- bash/now 5\.1-2\+deb11u1 amd64 \[installed,local\]
- coreutils/now 8\.32-4\+b1 amd64 \[installed,local\]
- dpkg/now 1\.20\.13 amd64 \[installed,local\]
- libncurses6/now 6\.2\+20201114-2\+deb11u2 amd64 \[installed,local\]
- ncurses-base/now 6\.2\+20201114-2\+deb11u2 all \[installed,local\]
- perl/now 5\.32\.1-4\+deb11u3 amd64 \[installed,local\]
- tzdata/now 2024a-0\+deb11u1 all \[installed,local\]
- name: "whoami"
command: "whoami"
expectedOutput: [r00t]
File renamed without changes.

0 comments on commit 3bca5d7

Please sign in to comment.