From 2fb4efa5310aeb9fd335b1b248c47341659cb812 Mon Sep 17 00:00:00 2001 From: Umair <58398786+Umair0343@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:04:01 +0500 Subject: [PATCH] Update set_test.go Pull Request Description: Changes Made Added a new test case TestParseSetArgs_InvalidKey in the config package to cover scenarios where an invalid key is provided in the set command arguments. Test Case Details Function Tested: TestParseSetArgs_InvalidKey Test Objective: Ensures that the parseSetArgs function correctly handles the scenario where an invalid key is provided, returning an appropriate error message. Test Input: Command arguments with an invalid key, e.g., invalidKey=value1. Expected Output: The function should return an error message indicating that the provided key is unknown, along with the list of supported keys. Motivation This new test case enhances the test coverage for the parseSetArgs function, ensuring robust handling of invalid keys during the configuration setting process. By validating that the function produces the expected error message for such cases, we contribute to the overall reliability of the codebase. This addition further strengthens the testing suite for the config package, promoting code quality and correctness. Signed-off-by: Umair <58398786+Umair0343@users.noreply.github.com> --- cmd/config/set_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/config/set_test.go b/cmd/config/set_test.go index 05250d23..c5f526b0 100644 --- a/cmd/config/set_test.go +++ b/cmd/config/set_test.go @@ -73,3 +73,9 @@ func TestParseSetArgs_Single(t *testing.T) { assert.Equal(t, "", setConfig.CloudReportURL) assert.Equal(t, "", setConfig.CloudAPIURL) } + +func TestParseSetArgs_InvalidKey(t *testing.T) { + args := []string{"invalidKey=value1"} + _, err := parseSetArgs(args) + assert.Equal(t, "key 'invalidKey' unknown . supported: accessKey/accountID/cloudAPIURL/cloudReportURL", err.Error()) +}