<commit_before>#!/usr/bin/env bats

load helpers

@test "config-flags-order-verification" {
  run_buildah 125 config cnt1 --author=user1
  check_options_flag_err "--author=user1"

  run_buildah 125 config cnt1 --arch x86_54
  check_options_flag_err "--arch"

  run_buildah 125 config cnt1 --created-by buildahcli --cmd "/usr/bin/run.sh" --hostname "localhost1"
  check_options_flag_err "--created-by"

  run_buildah 125 config cnt1 --annotation=service=cache
  check_options_flag_err "--annotation=service=cache"
}

@test "config-flags-verification" {
  run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch
  cid=$output
  run_buildah 125 config --label LABEL $cid
  expect_output --substring 'error adding label "LABEL": no value given'

  run_buildah 125 config --annotation ANNOTATION $cid
  expect_output --substring 'error adding annotation "ANNOTATION": no value given'

  run_buildah 125 config --healthcheck 'AB "CD' $cid
  expect_output --substring 'error parsing --healthcheck "AB \"CD": invalid command line string'

  run_buildah 125 config --healthcheck-interval ABCD $cid
  expect_output --substring 'error parsing --healthcheck-interval "ABCD": time: invalid duration ABCD'

  run_buildah 125 config --cmd 'AB "CD' $cid
  expect_output --substring 'error parsing --cmd "AB \"CD": invalid command line string'

  run_buildah 125 config --env ENV $cid
  expect_output --substring 'error setting env "ENV": no value given'

  run_buildah 125 config --shell 'AB "CD' $cid
  expect_output --substring 'error parsing --shell "AB \"CD": invalid command line string'
}

function check_matrix() {
  local setting=$1
  local expect=$2

  # matrix test: all permutations of .Docker.* and .OCIv1.* in all image types
  for image in docker oci; do
      for which in Docker OCIv1; do
	run_buildah inspect --type=image --format "{{.$which.$setting}}" scratch-image-$image
	expect_output "$expect"
    done
  done
}

@test "config entrypoint using single element in JSON array (exec form)" {
  run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch<commit_msg>Fix config-flags-verification test on F33<commit_after>#!/usr/bin/env bats

load helpers

@test "config-flags-order-verification" {
  run_buildah 125 config cnt1 --author=user1
  check_options_flag_err "--author=user1"

  run_buildah 125 config cnt1 --arch x86_54
  check_options_flag_err "--arch"

  run_buildah 125 config cnt1 --created-by buildahcli --cmd "/usr/bin/run.sh" --hostname "localhost1"
  check_options_flag_err "--created-by"

  run_buildah 125 config cnt1 --annotation=service=cache
  check_options_flag_err "--annotation=service=cache"
}

@test "config-flags-verification" {
  run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch
  cid=$output
  run_buildah 125 config --label LABEL $cid
  expect_output --substring 'error adding label "LABEL": no value given'

  run_buildah 125 config --annotation ANNOTATION $cid
  expect_output --substring 'error adding annotation "ANNOTATION": no value given'

  run_buildah 125 config --healthcheck 'AB "CD' $cid
  expect_output --substring 'error parsing --healthcheck "AB \"CD": invalid command line string'

  run_buildah 125 config --healthcheck-interval ABCD $cid
  expect_output --substring 'error parsing --healthcheck-interval "ABCD": time: invalid duration "?ABCD"?'

  run_buildah 125 config --cmd 'AB "CD' $cid
  expect_output --substring 'error parsing --cmd "AB \"CD": invalid command line string'

  run_buildah 125 config --env ENV $cid
  expect_output --substring 'error setting env "ENV": no value given'

  run_buildah 125 config --shell 'AB "CD' $cid
  expect_output --substring 'error parsing --shell "AB \"CD": invalid command line string'
}

function check_matrix() {
  local setting=$1
  local expect=$2

  # matrix test: all permutations of .Docker.* and .OCIv1.* in all image types
  for image in docker oci; do
      for which in Docker OCIv1; do
	run_buildah inspect --type=image --format "{{.$which.$setting}}" scratch-image-$image
	expect_output "$expect"
    done
  done
}

@test "config entrypoint using single element in JSON array (exec form)" {
  run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch
{'fraction_non_alphanumeric': 0.1088403041825095, 'fraction_numerical': 0.02328897338403042, 'mean_word_length': 4.0894800483675935, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6841643', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1289, 'n_words': 441}