File: run-unit-test

package info (click to toggle)
oras 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,752 kB
  • sloc: sh: 157; makefile: 147
file content (39 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
set -eux

pkg="oras"
AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)

echo "Testing inside tempdir ${AUTOPKGTEST_TMP}"
cd "${AUTOPKGTEST_TMP}"

# Setup make a zot registry
docker run -d -p 5000:5000 --name oras-autopkgtest ghcr.io/project-zot/zot-linux-amd64:latest

# Wait for zot to get up and running
sleep 5

exit_code=0
# Test: Push a simple file
echo "hello world" > artifact.txt
oras push --plain-http --insecure localhost:5000/hello-artifact:v1 \
    --artifact-type application/vnd.acme.rocket.config \
    artifact.txt:text/plain || exit_code=$?
if [ "$exit_code" != "0" ]; then
    echo "Exited with exit code: $exit_code"
fi

# Test: Pull the same file and check checksum
md5sum artifact.txt > checkmd5.md5
rm -f artifact.txt
oras pull localhost:5000/hello-artifact:v1
md5sum -c checkmd5.md5 || exit 1
rm -f artifact.txt

# Test: View referrers
oras discover localhost:5000/hello-artifact:v1

# Cleanup
trap "docker rm $(docker stop oras-autopkgtest)" 0 INT QUIT ABRT PIPE TERM

echo "All tests completed!"