-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update version command additions (#27)
Signed-off-by: Keith Zantow <[email protected]>
- Loading branch information
Showing
2 changed files
with
160 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package clio | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_versionInfoText(t *testing.T) { | ||
expected := `Application: the-name | ||
Version: the-version | ||
BuildDate: the-build-date | ||
GitCommit: the-commit | ||
GitDescription: the-description | ||
Platform: linux/amd64 | ||
GoVersion: go1.21.1 | ||
Compiler: gc | ||
Addition With A Long Line: some-value | ||
` | ||
got, err := versionInfo(runtimeInfo{ | ||
Identification: Identification{ | ||
Name: "the-name", | ||
Version: "the-version", | ||
GitCommit: "the-commit", | ||
GitDescription: "the-description", | ||
BuildDate: "the-build-date", | ||
}, | ||
GoVersion: "go1.21.1", | ||
Compiler: "gc", | ||
Platform: "linux/amd64", | ||
}, "text", func() (name string, value any) { | ||
return "Addition With A Long Line", "some-value" | ||
}) | ||
require.NoError(t, err) | ||
require.Equal(t, expected, got) | ||
} | ||
|
||
func Test_versionInfoJSON(t *testing.T) { | ||
expected := `{ | ||
"additionalValue": "some-value", | ||
"someValueWithSpacesAndUpper": "some-other-value", | ||
"application": "the-name", | ||
"buildDate": "the-build-date", | ||
"compiler": "gc", | ||
"gitCommit": "the-commit", | ||
"gitDescription": "the-description", | ||
"goVersion": "go1.21.1", | ||
"platform": "linux/amd64", | ||
"version": "the-version" | ||
}` | ||
got, err := versionInfo(runtimeInfo{ | ||
Identification: Identification{ | ||
Name: "the-name", | ||
Version: "the-version", | ||
GitCommit: "the-commit", | ||
GitDescription: "the-description", | ||
BuildDate: "the-build-date", | ||
}, | ||
GoVersion: "go1.21.1", | ||
Compiler: "gc", | ||
Platform: "linux/amd64", | ||
}, "json", func() (name string, value any) { | ||
return "additionalValue", "some-value" | ||
}, func() (name string, value any) { | ||
return "Some Value With Spaces and UPPER", "some-other-value" | ||
}) | ||
require.NoError(t, err) | ||
require.JSONEq(t, expected, got) | ||
} |