Skip to content

Commit

Permalink
feat(golang-rewrite): update asdf plugin test command to install a …
Browse files Browse the repository at this point in the history
…tool version in the test
  • Loading branch information
Stratus3D committed Dec 14, 2024
1 parent eb78a38 commit 3c4d1c9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ func pluginUpdateCommand(cCtx *cli.Context, logger *log.Logger, pluginName, ref
return err
}

func pluginTestCommand(l *log.Logger, args []string, _, _ string) {
func pluginTestCommand(l *log.Logger, args []string, toolVersion, _ string) {
conf, err := config.LoadConfig()
if err != nil {
l.Printf("error loading config: %s", err)
Expand Down Expand Up @@ -921,9 +921,21 @@ func pluginTestCommand(l *log.Logger, args []string, _, _ string) {
failTest(l, "Unable to list available versions")
}

if len(strings.Split(output.String(), " ")) < 1 {
allVersions := strings.Fields(output.String())
if len(allVersions) < 1 {
failTest(l, "list-all did not return any version")
}

// grab first version returned by list-all callback if no version provided as
// a CLI argument
if toolVersion == "" {
toolVersion = allVersions[0]
}

err = versions.InstallOneVersion(conf, plugin, toolVersion, false, os.Stdout, os.Stderr)
if err != nil {
failTest(l, "install exited with an error")
}
}

func failTest(logger *log.Logger, msg string) {
Expand Down

0 comments on commit 3c4d1c9

Please sign in to comment.