<commit_before>#!/bin/bash

function oneTimeSetUp() {
	source $HOMESHICK_FN_SRC
}

function setUp() {
	$HOMESHICK_FN --batch clone $REPO_FIXTURES/rc-files > /dev/null
}

function tearDown() {
	rm -rf "$HOMESICK/repos/rc-files"
}

function testUpToDate() {
	esc="\\u001b\\u005b"
	if $EXPECT_INSTALLED; then
		cat <<EOF | expect -f - > /dev/null
			spawn $HOMESHICK_BIN check rc-files
			expect -ex "${esc}1;36m     checking${esc}0m rc-files\r${esc}1;32m   up to date${esc}0m rc-files\r\n" {} default {exit 1}
EOF
	else
		startSkipping
	fi
	assertEquals "Failed verifying the check command output." 0 $?
}

function testBehind() {
	(cd "$HOMESICK/repos/rc-files"; git reset --hard HEAD^1) > /dev/null
	esc="\\u001b\\u005b"
	if $EXPECT_INSTALLED; then
		cat <<EOF | expect -f - > /dev/null
			spawn $HOMESHICK_BIN check rc-files
			expect -ex "${esc}1;36m     checking${esc}0m rc-files\r${esc}1;31m       behind${esc}0m rc-files\r\n" {} default {exit 1}
EOF
	else
		startSkipping
	fi
	assertEquals "Failed verifying the check command output." 0 $?
	(cd "$HOMESICK/repos/rc-files"; git reset --hard HEAD@{1}) > /dev/null
}

function testAhead() {
	(
		cd "$HOMESICK/repos/rc-files"<commit_msg>Unit test for check to test for spaces in reponame<commit_after>#!/bin/bash

function oneTimeSetUp() {
	source $HOMESHICK_FN_SRC
}

function setUp() {
	$HOMESHICK_FN --batch clone $REPO_FIXTURES/rc-files > /dev/null
}

function tearDown() {
	rm -rf "$HOMESICK/repos/rc-files"
}

function testUpToDate() {
	esc="\\u001b\\u005b"
	if $EXPECT_INSTALLED; then
		cat <<EOF | expect -f - > /dev/null
			spawn $HOMESHICK_BIN check rc-files
			expect -ex "${esc}1;36m     checking${esc}0m rc-files\r${esc}1;32m   up to date${esc}0m rc-files\r\n" {} default {exit 1}
EOF
	else
		startSkipping
	fi
	assertEquals "Failed verifying the check command output." 0 $?
}

function testUpToDateWithSpacesInRepoName() {
	$HOMESHICK_FN --batch clone "$REPO_FIXTURES/repo with spaces in name" > /dev/null
	esc="\\u001b\\u005b"
	if $EXPECT_INSTALLED; then
		cat <<EOF | expect -f - > /dev/null
			spawn $HOMESHICK_BIN check "repo with spaces in name"
			expect -ex "${esc}1;36m     checking${esc}0m repo with spaces in name\r${esc}1;32m   up to date${esc}0m repo with spaces in name\r\n" {} default {exit 1}
EOF
	else
		startSkipping
	fi
	assertEquals "Failed verifying the check command output." 0 $?
	rm -rf "$HOMESICK/repos/repo with spaces in name"
}

function testBehind() {
	(cd "$HOMESICK/repos/rc-files"; git reset --hard HEAD^1) > /dev/null
	esc="\\u001b\\u005b"
	if $EXPECT_INSTALLED; then
		cat <<EOF | expect -f - > /dev/null
			spawn $HOMESHICK_BIN check rc-files
			expect -ex "${esc}1;36m     checking${esc}0m rc-files\r${esc}1;31m       behind${esc}0m rc-files\r\n" {} default {exit 1}
EOF
	else
		startSkipping
	fi
	assertEquals "Failed verifying the check command output." 0 $?
	(cd "$HOMESICK/repos/rc-files"; git reset --hard HEAD@{1}) > /dev/null
}

function testAhead() {
	(
		cd "$HOMESICK/repos/rc-files"
{'fraction_non_alphanumeric': 0.14729458917835672, 'fraction_numerical': 0.028056112224448898, 'mean_word_length': 3.6651090342679127, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '879356', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1171, 'n_words': 297}