Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
modules = ../go/gomod2nix.toml;
pname = "snekcheck";
src = ../go;
version = "0.0";
version = "1.0.0";
};
in {
apps.snekcheck.program = "${pkg}/bin/snekcheck";
Expand Down
18 changes: 9 additions & 9 deletions spec/check_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ Describe "check"

Context "with no subdirectories"
create_valid_files() { for _ in $(seq 1 "$1"); do create_valid_file "$root"; done; }
BeforeEach "create_valid_files 20"
BeforeEach "create_valid_files 10 > /dev/null"

It "succeeds"
When call "$bin" "$root"
The status should be success
The output should include "21 valid filenames"
The output should include "11 valid filenames"
The output should include "0 invalid filenames"
The length of error should equal 0
End

Context "and one invalid file"
BeforeEach "create_invalid_file $root"
BeforeEach "create_invalid_file $root > /dev/null"

It "fails"
When call "$bin" "$root"
The status should be failure
The output should include "21 valid filenames"
The output should include "11 valid filenames"
The output should include "1 invalid filenames"
The error should include "invalid filenames found"
End
Expand All @@ -44,12 +44,12 @@ Describe "check"
End

Context "and one invalid directory"
BeforeEach "create_invalid_file $root"
BeforeEach "create_invalid_file $root > /dev/null"

It "fails"
When call "$bin" "$root"
The status should be failure
The output should include "21 valid filenames"
The output should include "11 valid filenames"
The output should include "1 invalid filenames"
The error should include "invalid filenames found"
End
Expand All @@ -66,19 +66,19 @@ Describe "check"

Context "with many subdirectories"
create_valid_files() { for _ in $(seq 1 "$1"); do create_valid_file "$2"; done; }
BeforeEach "create_valid_files 20 $root"
BeforeEach "create_valid_files 10 $root > /dev/null"
create_valid_directories() {
for _ in $(seq 1 "$1"); do
dir=$(create_valid_directory "$root")
create_valid_files "$1" "$dir"
done
}
BeforeEach "create_valid_directories 20"
BeforeEach "create_valid_directories 10 > /dev/null"

It "succeeds"
When call "$bin" "$root"
The status should be success
The output should include "441 valid filenames"
The output should include "121 valid filenames"
The output should include "0 invalid filenames"
The length of error should equal 0
End
Expand Down
12 changes: 6 additions & 6 deletions spec/fix_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ Describe "fix"

Context "with no subdirectories"
create_valid_files() { for _ in $(seq 1 "$1"); do create_valid_file "$root"; done; }
BeforeEach "create_valid_files 20"
BeforeEach "create_valid_files 10 > /dev/null"

It "succeeds"
When call "$bin" --fix "$root"
The status should be success
The output should include "21 valid filenames"
The output should include "11 valid filenames"
The output should include "0 filenames changed"
The length of error should equal 0
End

Context "and one invalid file"
create_and_assign_invalid_file() { invalid=$(create_invalid_file "$root"); }
BeforeEach "create_and_assign_invalid_file"
BeforeEach "create_and_assign_invalid_file > /dev/null"

It "succeeds given the root"
When call "$bin" --fix "$root"
Expand Down Expand Up @@ -75,7 +75,7 @@ Describe "fix"

Context "and one invalid directory"
create_and_assign_invalid_directory() { invalid=$(create_invalid_directory "$root"); }
BeforeEach "create_and_assign_invalid_directory"
BeforeEach "create_and_assign_invalid_directory > /dev/null"

It "succeeds given the root"
When call "$bin" --fix "$root"
Expand Down Expand Up @@ -126,14 +126,14 @@ Describe "fix"

Context "with many subdirectories"
create_valid_files() { for _ in $(seq 1 "$1"); do create_valid_file "$2"; done; }
BeforeEach "create_valid_files 20 $root"
BeforeEach "create_valid_files 10 $root > /dev/null"
create_valid_directories() {
for _ in $(seq 1 "$1"); do
dir=$(create_valid_directory "$root")
create_valid_files "$1" "$dir"
done
}
BeforeEach "create_valid_directories 20"
BeforeEach "create_valid_directories 10 > /dev/null"

It "succeeds"
When call "$bin" --fix "$root"
Expand Down
48 changes: 39 additions & 9 deletions spec/spec_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,52 @@ bin="./result/bin/snekcheck"

create_valid_directory() {
dir_name=$(echo "$RANDOM" | md5sum | head -c 20)
mkdir --parents "$1"/"$dir_name"
echo "$1"/"$dir_name"
dir_path="$1/$dir_name"

if [ -d "$dir_path" ]; then
create_valid_directory "$1"
else
mkdir --parents "$dir_path"
echo "$dir_path"
fi
}

create_valid_file() {
file_name=$(echo "$RANDOM" | md5sum | head -c 20)
mkdir --parents "$1"
touch "$1"/"$file_name"
echo "$1"/"$file_name"
file_path="$1/$file_name"

if [ -e "$file_path" ]; then
create_valid_file "$1"
else
mkdir --parents "$1"
touch "$file_path"
echo "$file_path"
fi
}

create_invalid_directory() {
mkdir --parents "$1"
mktemp --directory --tmpdir="$1" --quiet XXXInVaLiDXXX
dir_name=$(echo "$RANDOM" | md5sum | head -c 20)InVaLiD
dir_path="$1/$dir_name"

if [ -d "$dir_path" ]; then
create_valid_directory "$1"
else
mkdir --parents "$dir_path"
echo "$dir_path"
fi
}

create_invalid_file() {
mkdir --parents "$1"
mktemp --tmpdir="$1" --quiet XXXInVaLiDXXX
file_name=$(echo "$RANDOM" | md5sum | head -c 20)InVaLiD
file_path="$1/$file_name"

if [ -e "$file_path" ]; then
create_valid_file "$1"
else
mkdir --parents "$1"
touch "$file_path"
echo "$file_path"
fi
}

spec_helper_precheck() {
Expand Down