Skip to content

Commit

Permalink
Use 'check' instead of 'run' in all unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
extsoft committed Dec 22, 2017
1 parent 4613c66 commit d6af6a3
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/test/git-elegant-add.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ setup() {
}

@test "'add': successful adding of modified file" {
run git-elegant add
check git-elegant add
[ "$status" -eq 0 ]
}
12 changes: 6 additions & 6 deletions src/test/git-elegant-check.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@ preconditions() {

@test "'check': '-a' option is available" {
preconditions
run git-elegant check -a
check git-elegant check -a
[ "$status" -eq 0 ]
}

@test "'check': '--all' option is available" {
preconditions
run git-elegant check --all
check git-elegant check --all
[ "$status" -eq 0 ]
}

@test "'check': '-u' option is available" {
preconditions
run git-elegant check -u
check git-elegant check -u
[ "$status" -eq 0 ]
}

@test "'check': '--unstaged' option is available" {
preconditions
run git-elegant check --unstaged
check git-elegant check --unstaged
[ "$status" -eq 0 ]
}

@test "'check': '-s' option is available" {
preconditions
run git-elegant check -s
check git-elegant check -s
[ "$status" -eq 0 ]
}

@test "'check': '--staged' option is available" {
preconditions
run git-elegant check --staged
check git-elegant check --staged
[ "$status" -eq 0 ]
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/git-elegant-clear-local.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ teardown() {
}

@test "'clear-local': command is available" {
run git-elegant clear-local
check git-elegant clear-local
[ "$status" -eq 0 ]
}
4 changes: 2 additions & 2 deletions src/test/git-elegant-clone.bats
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ teardown() {
}

@test "'clone': raise an error if cloneable URL isn't set" {
run git-elegant clone
check git-elegant clone
[[ "${lines[0]}" =~ "Cloneable URL is not set" ]]
}

@test "'clone': clone the repo" {
run git-elegant clone https://github.com/extsoft/elegant-git.git
check git-elegant clone https://github.com/extsoft/elegant-git.git
[ "$status" -eq 0 ]
}
4 changes: 2 additions & 2 deletions src/test/git-elegant-commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ teardown() {
}

@test "'commands': print all available commands" {
run git-elegant commands
check git-elegant commands
[ "${lines[0]}" = "feature" ]
[ "${lines[1]}" = "pull" ]
[ "${lines[2]}" = "push" ]
Expand All @@ -24,6 +24,6 @@ teardown() {
}

@test "'commands': default exit code is 0" {
run git-elegant commands
check git-elegant commands
[ "$status" -eq 0 ]
}
12 changes: 6 additions & 6 deletions src/test/git-elegant-feature.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,38 @@ teardown() {
}

@test "'feature': branch with given name is created successfully" {
run git-elegant feature test-feature
check git-elegant feature test-feature
[ "$status" -eq 0 ]
}

@test "'feature': exit code is 255 when branch name isn't set" {
run git-elegant feature
check git-elegant feature
[ "$status" -eq 255 ]
}

@test "'feature': print error message when branch name isn't set" {
run git-elegant feature
check git-elegant feature
[[ "${lines[0]}" =~ "Feature name is not set" ]]
}

@test "'feature': use stash for available 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
check git-elegant feature test-feature
[ "$status" -eq 0 ]
}

@test "'feature': ignore stash if there are no changes" {
fake-pass git "stash save elegant-git" "No local changes to save"
run git-elegant feature test-feature
check git-elegant feature test-feature
[ "$status" -eq 0 ]
}

@test "'feature': exit code is 100 when stash wasn't applied" {
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
check git-elegant feature test-feature
[ "$status" -eq 100 ]
}
2 changes: 1 addition & 1 deletion src/test/git-elegant-init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ teardown() {
}

@test "'init': command is available" {
run git-elegant init
check git-elegant init
[ "$status" -eq 0 ]
}
4 changes: 2 additions & 2 deletions src/test/git-elegant-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ teardown() {
fake-pass git "fetch --tags"
fake-pass git pull

run git-elegant pull
check git-elegant pull
[ "$status" -eq 0 ]
}

Expand All @@ -20,6 +20,6 @@ teardown() {
fake-pass git "fetch --tags"
fake-pass git pull

run git-elegant pull master
check git-elegant pull master
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion src/test/git-elegant-push-after-rebase.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ teardown() {
}

@test "'push-after-rebase': command is available" {
run git-elegant push-after-rebase
check git-elegant push-after-rebase
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion src/test/git-elegant-push.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ setup() {
}

@test "'push': command is available" {
run git-elegant push
check git-elegant push
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion src/test/git-elegant-rebase.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ teardown() {
}

@test "'rebase': command is available" {
run git-elegant rebase
check git-elegant rebase
[ "$status" -eq 0 ]
}

0 comments on commit d6af6a3

Please sign in to comment.