test: add mock client in UT for azurefile_dataplane_client.go #2350
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new
ShareClientInterface
to theazurefile
package, refactors the existing code to use this interface, and adds mock implementations for testing. The main changes include defining the new interface, updating methods to use the interface, and modifying tests to use mock clients.Introduction of
ShareClientInterface
:ShareClientInterface
with methods forGetProperties
,Create
,Delete
, andSetProperties
inpkg/azurefile/azurefile_dataplane_client.go
.newShareClient
function to return an instance ofShareClientInterface
.Refactoring to use
ShareClientInterface
:CreateFileShare
method to usenewShareClient
instead of directly callingf.Client.NewShareClient
.DeleteFileShare
method to usenewShareClient
.ResizeFileShare
method to usenewShareClient
.GetFileShareQuota
method to usenewShareClient
.Testing improvements:
ShareClientInterface
for unit tests inpkg/azurefile/azurefile_dataplane_client_test.go
.CreateFileShare
,DeleteFileShare
,ResizeFileShare
, andGetFileShareQuota
to check for successful operations instead of expecting errors. [1] [2] [3] [4]<!-- Thanks for sending a pull request! Here are some tips for you:https://git.k8s.io/community/contributors/devel/release.md#issue-kind-label
-->
What type of PR is this?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Requirements:
Special notes for your reviewer:
Release note: