Skip to content

Commit

Permalink
version Flag corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
Aziz Ishan-Khojaev committed Mar 13, 2024
1 parent fbe89a5 commit 156a782
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newUpdateCmd(c *config) *cobra.Command {
},
}

updateCmd.Flags().StringP("version", "v", "", `the version to update to, by default updates to the supported version, use "latest" to update to latest version`)
updateDoCmd.Flags().StringP("version", "v", "", `the version to update to, by default updates to the supported version, use "latest" to update to latest version`)

updateCmd.AddCommand(updateCheckCmd)
updateCmd.AddCommand(updateDoCmd)
Expand Down
29 changes: 29 additions & 0 deletions cmd/update_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

// import (
// "testing"

// "github.com/metal-stack/metalctl/cmd/completion"
// "github.com/spf13/afero"
// )

// func TestUpdateDoCommand(t *testing.T) {
// c := &config{fs: afero.NewMemMapFs(), out: nil, driverURL: "", comp: &completion.Completion{}, client: nil, log: nil, describePrinter: nil, listPrinter: nil} // Initialize your config here as needed
// test := newRootCmd(c)
// //updateCmd := newUpdateCmd(c)

// // Simulate "update do --version v0.15.3"
// test.SetArgs([]string{"update", "do", "--version", "v0.15.3"})

// // Execute the command
// err := test.Execute()
// if err != nil {
// t.Fatalf("updateCmd.Execute() failed: %v", err)
// }

// // Assert that desired version is set to "v0.15.3"
// // This step assumes you have a way to verify the version was set correctly,
// // such as checking a variable in your application that should be set based on the flag.
// // Since your current implementation directly uses Viper and updater.New(),
// // you might need to refactor to make it testable or mock certain parts.
// }

0 comments on commit 156a782

Please sign in to comment.