Add devshell and initial bats tests
This commit is contained in:
parent
af8fae68fe
commit
d3b3862040
4 changed files with 102 additions and 4 deletions
50
test/mechanicaldiff.bats
Executable file
50
test/mechanicaldiff.bats
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
setup() {
|
||||
set -euo pipefail
|
||||
|
||||
bats_load_library bats-support
|
||||
bats_load_library bats-assert
|
||||
|
||||
DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")" >/dev/null 2>&1 && pwd)"
|
||||
PATH="$DIR/../bin:$PATH"
|
||||
}
|
||||
|
||||
@test "keeps hunk when replacement matches" {
|
||||
run bash -c 'cat <<"EOF" | mechanicaldiff.py foo bar
|
||||
diff --git a/file.txt b/file.txt
|
||||
index 1111111..2222222 100644
|
||||
--- a/file.txt
|
||||
+++ b/file.txt
|
||||
@@ -1,1 +1,1 @@
|
||||
-foo
|
||||
+bar
|
||||
EOF'
|
||||
assert_success
|
||||
expected="$(
|
||||
cat <<'EOF'
|
||||
diff --git a/file.txt b/file.txt
|
||||
index 1111111..2222222 100644
|
||||
--- a/file.txt
|
||||
+++ b/file.txt
|
||||
@@ -1,1 +1,1 @@
|
||||
-foo
|
||||
+bar
|
||||
EOF
|
||||
)"
|
||||
assert_output "$expected"
|
||||
}
|
||||
|
||||
@test "drops diff when replacement does not match" {
|
||||
run bash -c 'cat <<"EOF" | mechanicaldiff.py foo bar
|
||||
diff --git a/file.txt b/file.txt
|
||||
index 1111111..2222222 100644
|
||||
--- a/file.txt
|
||||
+++ b/file.txt
|
||||
@@ -1,1 +1,1 @@
|
||||
-foo
|
||||
+baz
|
||||
EOF'
|
||||
assert_success
|
||||
assert_output ""
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue