-
Notifications
You must be signed in to change notification settings - Fork 45
Commit 09913c9
authored
Add additional test coverage for helper functions in Util (#4651)
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit adds test coverage helper functions in Util
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the lint errors and handles errors.
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit
- fixes the lint errors and handles errors.
- adds test coverage for OpenFileArg, ExpandFileArgs, functions
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage.
This commit
- fixes the lint errors and handles errors.
- Adds test coverage for LoadCredentials function
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the lint errors after fixing lint version.
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit adds test coverage for RevokeToken function.
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit adds test coverage for the following functions by addressing the review feedback
- GetConfigDirPath
- GetGrpcConnection
- SaveCredentials
- RemoveCredentials
- RefreshCredentials
- LoadCredentials
- RevokeToken
- GetJsonFromProto
- GetYamlFromProto
- TestOpenFileArg
- ExpandFileArgs
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- TestGetConfigDirPath; Change from mu to envLock
- TestGetGrpcConnection: Moved deferred call up next to the os.Setenv call to reset env variable.
- TestSaveCredentials: Add lock so that config dir path is retrieved correctly.
- TestRemoveCredentials: Added deferred call up next to the os.Setenv call to reset env variable.
- TestLoadCredentials: Removed the statement that capture range variable and removed commented code, moved the deferred call up next to the resource it creates.
- TestOpenFileArg: Add t.TempDir() to create test the file.
- TestRevokeToken: Add a func(t *testing.T) *httptest.Server in the test cases which constructs the server.
- ExpandFileArgs: Using slices.EqualFunc with an anonymous function
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- Add envLock mutex to ensure that all the tests that run t.SetEnv("XDG_CONFIG...") need to be prevented from running at the same time as each other.
- TestGetConfigDirPath: Added deferred call up next to the os.Setenv call to reset env variable.
- TestOpenFileArg* Removed if condition.
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- Add a helper function SetEnvVar just to make sure that mutex lock handle things consistently
- Fix all test functions that require mutex with above helper function
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- Fix lint errors
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- Remove the line tt := tt to capture the range variable in the functions.
- Normalize JSON strings by removing all whitespaces and new lines in TestGetYamlFromProto
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- TestOpenFileArg: create testfile.txt outside the test case code, to avoid needing as much conditional logic in the test.
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- TestExpandFileArgs: Removed os.RemoveAll(testDir) line
- Changed name to setEnvVar and fixed all references
- TestGetGrpcConnection: use setEnvVar to set env variable
- TestGetJsonFromProto: Normalize json to handle empty space
- remved helper function createTestServer
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- setEnvVar: Fixed setting env to original value using t.Cleanup()
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- introduced two separate mutex locks such as envLockXdgConfigHome, envLockMinderAuthToken
- setEnvVar: parameterise mutex lock
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
* Add additional test coverage for helper functions in Util
Currently helper functions in Util lacks test coverage
This commit fixes the following functions by addressing the review feedback.
- Added lint comment //nolint:gosec // This is not a hardcoded credential
Signed-off-by: Kugamoorthy Gajananan <[email protected]>
---------
Signed-off-by: Kugamoorthy Gajananan <[email protected]>1 parent 58972c8 commit 09913c9Copy full SHA for 09913c9
1 file changed
+724
-1
lines changed
0 commit comments