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

# Tests pushing and pulling with the v1 registry

load ../helpers

hostname=${TEST_REGISTRY:-"localregistry"}
host="$hostname:5011"

repo=${TEST_REPO:-"hello-world"}
tag=${TEST_TAG:-"latest"}
image="${repo}:${tag}"

function setup() {
	if [ "$TEST_SKIP_PULL" == "" ]; then
		docker pull $image
	fi
}

function build() {
	docker build --no-cache -t $1 - <<DOCKERFILE
FROM $image
MAINTAINER <EMAIL>
DOCKERFILE
}

@test "Test v1 push and pull" {
	imagename=$host/testv1push
	run build $imagename
	[ "$status" -eq 0 ]

	run docker push $imagename
	echo $output
	[ "$status" -eq 0 ]

	# Remove imagename
	run docker rmi $imagename
	[ "$status" -eq 0 ]

	run docker pull $imagename
	echo $output
	[ "$status" -eq 0 ]

	imageid1=$(docker images -q --no-trunc $imagename)

	run docker rmi $imagename
	[ "$status" -eq 0 ]

	run docker pull $imagename
	[ "$status" -eq 0 ]

	imageid2=$(docker images -q --no-trunc $imagename)
	[ "$imageid1" == "$imageid2" ]
}

<commit_msg>Add v1 test to run after pull<commit_after>#!/usr/bin/env bats

# Tests pushing and pulling with the v1 registry

load ../helpers

hostname=${TEST_REGISTRY:-"localregistry"}
host="$hostname:5011"

repo="hello-world"
tag="latest"
image="${repo}:${tag}"

function setup() {
	if [ "$TEST_SKIP_PULL" == "" ]; then
		docker pull $image
	fi
}

function build() {
	docker build --no-cache -t $1 - <<DOCKERFILE
FROM $image
MAINTAINER <EMAIL>
DOCKERFILE
}

function createAndPushImage() {
	build $1
	docker push $1
	docker rmi $1
}

@test "Test v1 push and pull" {
	imagename=$host/testv1push
	run createAndPushImage $imagename
	echo $output
	[ "$status" -eq 0 ]

	run docker pull $imagename
	echo $output
	[ "$status" -eq 0 ]

	imageid1=$(docker images -q --no-trunc $imagename)

	run docker rmi $imagename
	[ "$status" -eq 0 ]

	run docker pull $imagename
	[ "$status" -eq 0 ]

	imageid2=$(docker images -q --no-trunc $imagename)
	[ "$imageid1" == "$imageid2" ]
}

@test "Test v1 run after pull" {
	imagename=$host/testv1run
	run createAndPushImage $imagename
	echo $output
	[ "$status" -eq 0 ]

	run docker pull $imagename
	echo $output
	[ "$status" -eq 0 ]

	run docker images --no-trunc
	echo "$output"
	[ "$status" -eq 0 ]
	
	run docker run $imagename
	[ "$status" -eq 0 ]

	trimmed=$(echo -e "${output}" | cut -c1-17 | head -n 2 | tail -n 1)
	echo "\"$trimmed\""
	teststr="Hello from Docker"
	[ "$trimmed" == "$teststr" ]
}

{'fraction_non_alphanumeric': 0.16026435357290375, 'fraction_numerical': 0.020239570425444033, 'mean_word_length': 3.796039603960396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '6110193', 'n_tokens_mistral': 976, 'n_tokens_neox': 904, 'n_words': 268}