Skip to content

Commit

Permalink
Fix broken unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Feb 13, 2025
1 parent 7393531 commit eac6855
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestExecute_Version(t *testing.T) {
{
name: "success",
args: []string{"gup", "version"},
stdout: []string{"gup version (under Apache License version 2.0)", ""},
stdout: []string{"gup version (devel) (under Apache License version 2.0)", ""},
},
}
for _, tt := range tests {
Expand Down
6 changes: 4 additions & 2 deletions internal/cmdinfo/cmdinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ const Name = "gup"
// GetVersion return gup command version.
// Version global variable is set by ldflags.
func GetVersion() string {
version := "unknown"
version := "(devel)"
if Version != "" {
version = Version
} else if buildInfo, ok := debug.ReadBuildInfo(); ok {
version = buildInfo.Main.Version
if buildInfo.Main.Version != "" {
version = buildInfo.Main.Version
}
}
return fmt.Sprintf("%s version %s (under Apache License version 2.0)", Name, version)
}
4 changes: 2 additions & 2 deletions internal/goutil/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func ExampleGoBin() {
// Output: Example GoBin: OK
}

func ExampleInstall() {
func ExampleInstallLatest() {
// Install installs an executable from a Go package.
err := goutil.InstallLatest("example.com/unknown_user/unknown_package")

Expand All @@ -160,7 +160,7 @@ func ExampleInstall() {
// Output: Example Install: OK
}

func ExampleIsAlreadyUpToDate() {
func ExamplePackage_IsAlreadyUpToDate() {
// Create Version object with Current and Latest package and Go versions
ver := goutil.Version{
Current: "v1.9.0",
Expand Down

0 comments on commit eac6855

Please sign in to comment.