Skip to content

Commit

Permalink
Add tests for version flags
Browse files Browse the repository at this point in the history
  • Loading branch information
sds committed Oct 31, 2016
1 parent 2825e74 commit 7727034
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Option | Description
`-f` | Force creation of new container (destroying old one if it exists)
`-q` | Silence Dock-related output (so only output from command run in the container is shown)
`-v` | Display version information
`-V` | Display extended version information (for bug reports)
`-V` | Display verbose version information (for bug reports)

### Attach to an already-running container

Expand Down
2 changes: 1 addition & 1 deletion bin/dock
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ display_debug_version_info() {
echo "Docker executable not found in PATH!"
fi
echo "Bash: $BASH_VERSION"
echo "OS: $(uname -v)"
echo "OS: $(uname -a)"
}

display_usage() {
Expand Down
37 changes: 37 additions & 0 deletions test/options/verbose_version.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bats

load ../utils

setup() {
destroy_all_containers
original_dir="$(pwd)"
cd "$(create_repo my-project)"
}

teardown() {
cd "${original_dir}"
}

@test "when -V flag specified it displays the Dock version" {
run dock -V
[ "$status" -eq 0 ]
[[ "$output" =~ Dock:\ +[0-9]+\.[0-9]+\.[0-9]+ ]]
}

@test "when -V flag specified it displays the Docker version" {
run dock -V
[ "$status" -eq 0 ]
[[ "$output" =~ Docker:\ +Docker\ version\ [0-9]+\.[0-9]+\.[0-9]+ ]]
}

@test "when -V flag specified it displays the Bash version" {
run dock -V
[ "$status" -eq 0 ]
[[ "$output" =~ Bash:\ +"$BASH_VERSION" ]]
}

@test "when -V flag specified it displays the OS version" {
run dock -V
[ "$status" -eq 0 ]
[[ "$output" =~ OS:\ +$(uname -a) ]]
}
19 changes: 19 additions & 0 deletions test/options/version.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bats

load ../utils

setup() {
destroy_all_containers
original_dir="$(pwd)"
cd "$(create_repo my-project)"
}

teardown() {
cd "${original_dir}"
}

@test "when -v flag specified it displays the Dock version" {
run dock -v
[ "$status" -eq 0 ]
[[ "$output" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]
}

0 comments on commit 7727034

Please sign in to comment.