-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version flag to print version and exit (#394)
## Changes With this PR, all of the command below print version and exit: ``` $ databricks -v Databricks CLI v0.100.1-dev+4d3fa76 $ databricks --version Databricks CLI v0.100.1-dev+4d3fa76 $ databricks version Databricks CLI v0.100.1-dev+4d3fa76 ``` ## Tests Added integration test for each flag or command.
- Loading branch information
Showing
4 changed files
with
36 additions
and
9 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
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,29 @@ | ||
package internal | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/databricks/cli/internal/build" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var expectedVersion = fmt.Sprintf("Databricks CLI v%s\n", build.GetInfo().Version) | ||
|
||
func TestVersionFlagShort(t *testing.T) { | ||
stdout, stderr := RequireSuccessfulRun(t, "-v") | ||
assert.Equal(t, expectedVersion, stdout.String()) | ||
assert.Equal(t, "", stderr.String()) | ||
} | ||
|
||
func TestVersionFlagLong(t *testing.T) { | ||
stdout, stderr := RequireSuccessfulRun(t, "--version") | ||
assert.Equal(t, expectedVersion, stdout.String()) | ||
assert.Equal(t, "", stderr.String()) | ||
} | ||
|
||
func TestVersionCommand(t *testing.T) { | ||
stdout, stderr := RequireSuccessfulRun(t, "version") | ||
assert.Equal(t, expectedVersion, stdout.String()) | ||
assert.Equal(t, "", stderr.String()) | ||
} |