Skip to content

Commit

Permalink
Update tests to handle 'git elegant' calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKarabaza committed Oct 10, 2017
1 parent 1c95b19 commit 5c80be1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/test/git-elegant-check.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load commons
setup() {
fake-pass git "diff --check"
fake-pass git "diff --cached --check"
fake-pass git "elegant check --all"
}

@test "exit code is 0 when run 'git-elegant check -a'" {
Expand Down
4 changes: 1 addition & 3 deletions src/test/git-elegant-clear-local.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ load fake-read

setup() {
fake-pass git "branch -lvv" "first [gone]"
fake-pass git "checkout master"
fake-pass git "fetch --tags"
fake-pass git pull
fake-pass git "elegant pull master"
fake-pass git "branch -d first"
}

Expand Down
7 changes: 3 additions & 4 deletions src/test/git-elegant-feature.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
load commons

setup() {
fake-pass git "checkout master"
fake-pass git "fetch --tags"
fake-pass git pull
fake-pass git "elegant pull master"
fake-pass git "checkout -b test-feature"
fake-pass git "stash save elegant-git"
fake-pass git "stash apply stash^{/elegant-git}"
}

@test "exit code is 0 when run 'git-elegant feature test-feature'" {
Expand All @@ -28,6 +25,7 @@ setup() {

@test "exit code is 0 when run 'git-elegant feature' with changes" {
fake-pass git "stash save elegant-git" "Saved working directory"
fake-pass git "stash apply stash^{/elegant-git}"
fake-pass git "stash drop stash@{0}"
run git-elegant feature test-feature
[ "$status" -eq 0 ]
Expand All @@ -41,6 +39,7 @@ setup() {

@test "exit code is 100 when run 'git-elegant feature' with error at 'git stash drop'" {
fake-pass git "stash save elegant-git" "Saved working directory"
fake-pass git "stash apply stash^{/elegant-git}"
fake-fail git "stash drop stash@{0}"
run git-elegant feature test-feature
[ "$status" -eq 100 ]
Expand Down
6 changes: 2 additions & 4 deletions src/test/git-elegant-push-after-rebase.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ load commons
load fake-read

setup() {
fake-pass git branch *master
fake-pass git "push -u origin master:master"
fake-pass git "fetch --tags"
fake-pass git "rebase origin/master"
fake-pass git "elegant rebase"
fake-pass git "elegant push"
}

@test "exit code is 0 when run 'git-elegant push-after-rebase'" {
Expand Down
24 changes: 12 additions & 12 deletions src/test/git-elegant.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ load commons

@test "print available commands when run 'git-elegant commands'" {
run git-elegant commands
[[ "${lines[0]}" =~ "feature" ]]
[[ "${lines[1]}" =~ "pull" ]]
[[ "${lines[2]}" =~ "push" ]]
[[ "${lines[3]}" =~ "push-after-rebase" ]]
[[ "${lines[4]}" =~ "rebase" ]]
[[ "${lines[5]}" =~ "init" ]]
[[ "${lines[6]}" =~ "clone" ]]
[[ "${lines[7]}" =~ "add" ]]
[[ "${lines[8]}" =~ "clear-local" ]]
[[ "${lines[9]}" =~ "configure" ]]
[[ "${lines[10]}" =~ "check" ]]
[ "${lines[0]}" = "feature" ]
[ "${lines[1]}" = "pull" ]
[ "${lines[2]}" = "push" ]
[ "${lines[3]}" = "push-after-rebase" ]
[ "${lines[4]}" = "rebase" ]
[ "${lines[5]}" = "init" ]
[ "${lines[6]}" = "clone" ]
[ "${lines[7]}" = "add" ]
[ "${lines[8]}" = "clear-local" ]
[ "${lines[9]}" = "configure" ]
[ "${lines[10]}" = "check" ]
[ ${#lines[@]} -eq 11 ]
}


@test "exit code is 10 when run 'git-elegant'" {
fake-pass git "elegant commands"
run git-elegant
echo $status
[ "$status" -eq 10 ]
}

Expand Down

0 comments on commit 5c80be1

Please sign in to comment.