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

load helpers

@test "inspect-flags-order-verification" {
  run_buildah 1 inspect img1 -f "{{.ContainerID}}" -t="container"
  check_options_flag_err "-f"

  run_buildah 1 inspect img1 --format="{{.ContainerID}}"
  check_options_flag_err "--format={{.ContainerID}}"

  run_buildah 1 inspect img1 -t="image"
  check_options_flag_err "-t=image"
}

@test "inspect" {
	cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
	run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image
	
	buildah_version=$(buildah --version | awk '{ print $3 }')
	out1=$(buildah inspect --format '{{.OCIv1.Config}}' alpine)
	out2=$(buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image | sed "s/io.buildah.version:${buildah_version}//g")

	[ "$out1" != "" ]
	[ "$out1" = "$out2" ]
}

@test "inspect-config-is-json" {
	cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
	out=$(buildah inspect alpine | grep "Config" | grep "{" | wc -l)
	# if there is "{" it's a JSON string
	[ "$out" -ne "0" ]
	buildah rm $cid
	buildah rmi -f alpine
}

@test "inspect-manifest-is-json" {
	cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
	out=$(buildah inspect alpine | grep "Manifest" | grep "{" | wc -l)<commit_msg>Tests: Add inspect test check steps<commit_after>#!/usr/bin/env bats

load helpers

@test "inspect-flags-order-verification" {
  run_buildah 1 inspect img1 -f "{{.ContainerID}}" -t="container"
  check_options_flag_err "-f"

  run_buildah 1 inspect img1 --format="{{.ContainerID}}"
  check_options_flag_err "--format={{.ContainerID}}"

  run_buildah 1 inspect img1 -t="image"
  check_options_flag_err "-t=image"
}

@test "inspect" {
	cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
	run_buildah commit --signature-policy ${TESTSDIR}/policy.json "$cid" alpine-image
	
	buildah_version=$(buildah --version | awk '{ print $3 }')
	out1=$(buildah inspect --format '{{.OCIv1.Config}}' alpine)
	out2=$(buildah inspect --type image --format '{{.OCIv1.Config}}' alpine-image | sed "s/io.buildah.version:${buildah_version}//g")

	[ "$out1" != "" ]
	[ "$out1" = "$out2" ]

	imageid=$(buildah images -q alpine-image)
	containerid=$(buildah containers -q)

	out3=$(buildah inspect --format '{{.OCIv1.Config}}' $containerid)
	out4=$(buildah inspect --type image --format '{{.OCIv1.Config}}' $imageid)
	[ "$out3" = "$out1" ]
	[ "$out4" = "$out1" ]

	buildah rm $cid
	buildah rmi alpine-image alpine
}

@test "inspect-config-is-json" {
	cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
	out=$(buildah inspect alpine | grep "Config" | grep "{" | wc -l)
	# if there is "{" it's a JSON string
	[ "$out" -ne "0" ]
	buildah rm $cid
	buildah rmi -f alpine
}

@test "inspect-manifest-is-json" {
	cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
	out=$(buildah inspect alpine | grep "Manifest" | grep "{" | wc -l)
{'fraction_non_alphanumeric': 0.18578512396694216, 'fraction_numerical': 0.01256198347107438, 'mean_word_length': 4.280977312390925, 'pattern_counts': {'":': 0, '<': 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': '2597249', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1116, 'n_words': 262}