From 772703425f0baa38ac5d057433d58b4e92ac6552 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Mon, 31 Oct 2016 14:23:01 -0700 Subject: [PATCH] Add tests for version flags --- README.md | 2 +- bin/dock | 2 +- test/options/verbose_version.bats | 37 +++++++++++++++++++++++++++++++ test/options/version.bats | 19 ++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 test/options/verbose_version.bats create mode 100644 test/options/version.bats diff --git a/README.md b/README.md index 0b6b983..abc3f44 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/dock b/bin/dock index 89b9801..c964084 100755 --- a/bin/dock +++ b/bin/dock @@ -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() { diff --git a/test/options/verbose_version.bats b/test/options/verbose_version.bats new file mode 100644 index 0000000..4ff54fd --- /dev/null +++ b/test/options/verbose_version.bats @@ -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) ]] +} diff --git a/test/options/version.bats b/test/options/version.bats new file mode 100644 index 0000000..844c718 --- /dev/null +++ b/test/options/version.bats @@ -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]+ ]] +}