From 156a782d36df1ec45887f1c7587f56843a1926b5 Mon Sep 17 00:00:00 2001 From: Aziz Ishan-Khojaev Date: Wed, 13 Mar 2024 15:07:28 +0100 Subject: [PATCH 1/2] 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 0833223..24963b2 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 0000000..c71e368 --- /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. +// } From 297ee308a82c6f71afcb0ddb5ebc84c319f0a78b Mon Sep 17 00:00:00 2001 From: Gerrit Date: Tue, 2 Apr 2024 14:00:53 +0200 Subject: [PATCH 2/2] Remove comments. --- cmd/update_test.go | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 cmd/update_test.go diff --git a/cmd/update_test.go b/cmd/update_test.go deleted file mode 100644 index c71e368..0000000 --- a/cmd/update_test.go +++ /dev/null @@ -1,29 +0,0 @@ -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. -// }