-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move 'fake's to separate addons file
- Loading branch information
Showing
15 changed files
with
73 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
MOCK_DIR="/tmp/elegant-git-mock" | ||
export PATH=$MOCK_DIR:$PATH | ||
|
||
|
||
fake() { | ||
# @todo #89 Implement logging of commands execution like in addons-git.bash | ||
|
||
# sample: fake <command> <subcommand> <exit> <stdout> <stderr> | ||
BASENAME=$(basename $1) | ||
PROGRAM_PATH="$MOCK_DIR/$BASENAME-app" | ||
FIXTURE_HOME="$PROGRAM_PATH/$(echo "$2" | sed 's/[^0-9a-zA-Z]*//g')" | ||
MOCK="$MOCK_DIR/$BASENAME" | ||
|
||
[ -d "$FIXTURE_HOME" ] && rm -r "$FIXTURE_HOME" | ||
mkdir -p "$FIXTURE_HOME" | ||
echo -e "$3" > "$FIXTURE_HOME/exit_code" | ||
echo -e "$4" > "$FIXTURE_HOME/stdout" | ||
echo -e "$5" > "$FIXTURE_HOME/stderr" | ||
|
||
[ -e "$MOCK" ] && rm -r "$MOCK" | ||
echo "#!/usr/bin/env bash | ||
PROGRAM_PATH=\"$MOCK_DIR/$BASENAME-app\" | ||
FIXTURE_HOME=\"\$PROGRAM_PATH/\$(echo \"\$@\" | sed 's/[^0-9a-zA-Z]*//g')\" | ||
cat \"\$FIXTURE_HOME/stdout\" | ||
cat \"\$FIXTURE_HOME/stderr\" >&2 | ||
read -r exit_code < \"\$FIXTURE_HOME/exit_code\" | ||
exit \$exit_code | ||
" > "$MOCK" | ||
chmod +x "$MOCK" | ||
} | ||
|
||
fake-pass() { | ||
# sample: fake-pass <command> <subcommand> <stdout> | ||
COMMAND="$1"; shift | ||
SUBCOMMAND="$1"; shift | ||
fake "$COMMAND" "$SUBCOMMAND" 0 "$@" | ||
} | ||
|
||
fake-fail() { | ||
# sample: fake-fail <command> <subcommand> <stderr> | ||
COMMAND="$1"; shift | ||
SUBCOMMAND="$1"; shift | ||
fake "$COMMAND" "$SUBCOMMAND" 100 " " "$@" | ||
} | ||
|
||
teardown() { | ||
# @todo #89 Use $BATS_TMPDIR instead of teardown methods for fakes deletion | ||
#teardown for bats tests | ||
if [ -d "$MOCK_DIR" ]; then | ||
rm -r "$MOCK_DIR" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
load addons-common | ||
load addons-git | ||
load addons-fake | ||
|
||
|
||
preconditions() { | ||
fake-pass git "diff --check" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
load addons-common | ||
load addons-read | ||
load addons-cd | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git clone | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
load addons-common | ||
load addons-read | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git "elegant commands" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/env bats -ex | ||
|
||
load addons-common | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git "elegant pull master" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
load addons-common | ||
load addons-read | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git init | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
load addons-common | ||
load addons-read | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git "elegant rebase" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
load addons-common | ||
load addons-read | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git branch *master | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/env bats | ||
|
||
load addons-common | ||
load addons-fake | ||
|
||
setup() { | ||
fake-pass git "fetch --tags" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters