From 156a782d36df1ec45887f1c7587f56843a1926b5 Mon Sep 17 00:00:00 2001 From: Aziz Ishan-Khojaev Date: Wed, 13 Mar 2024 15:07:28 +0100 Subject: [PATCH] version Flag corrected --- cmd/update.go | 2 +- cmd/update_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cmd/update_test.go diff --git a/cmd/update.go b/cmd/update.go index 08332230..24963b2d 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -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) diff --git a/cmd/update_test.go b/cmd/update_test.go new file mode 100644 index 00000000..c71e3689 --- /dev/null +++ b/cmd/update_test.go @@ -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. +// }