File: 620-option-conflicts.bats

package info (click to toggle)
podman 5.4.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,124 kB
  • sloc: sh: 6,119; perl: 2,710; python: 2,258; ansic: 1,556; makefile: 1,022; xml: 121; ruby: 42; awk: 12; csh: 8
file content (54 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (3)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bats   -*- bats -*-
#
# options that cannot be set together
#

load helpers


# bats test_tags=ci:parallel
@test "options that cannot be set together" {
    skip_if_remote "not much point testing remote, and container-cleanup fails anyway"

    tests="
create,run        | --cpu-period=1 | --cpus=2               | $IMAGE
create,run        | --cpu-quota=1  | --cpus=2               | $IMAGE
create,run        | --no-hosts     | --add-host=foo:1.1.1.1 | $IMAGE
create,run        | --userns=bar   | --pod=foo              | $IMAGE
container cleanup | --all          | --exec=foo
container cleanup | --exec=foo     | --rmi                  | foo
"

    # Run all tests, continue even if any fail
    defer-assertion-failures

    # FIXME: parse_table is what does all the work, giving us test cases.
    while read subcommands opt1 opt2 args; do
        opt1_name=${opt1%=*}
        opt2_name=${opt2%=*}

        readarray -d, -t subcommand_list <<<$subcommands
        for subcommand in "${subcommand_list[@]}"; do
            run_podman 125 $subcommand $opt1 $opt2 $args
            is "$output" "Error: $opt1_name and $opt2_name cannot be set together" \
               "podman $subcommand $opt1 $opt2"

            # Reverse order
            run_podman 125 $subcommand $opt2 $opt1 $args
            is "$output" "Error: $opt1_name and $opt2_name cannot be set together" \
               "podman $subcommand $opt2 $opt1"
        done
    done < <(parse_table "$tests")

    # Different error message; cannot be tested with the other ones above
    for opt in arch os; do
        for cmd in create pull; do
            run_podman 125 $cmd --platform=foo --$opt=bar sdfsdf
            is "$output" "Error: --platform option can not be specified with --arch or --os" \
               "podman $cmd --platform + --$opt"
        done
    done
}


# vim: filetype=sh