Repository navigation
test(go): add unit test suites and CI test verification for quickstart and azure-auth - #9363
Merged
Vincent Biret (baywet) merged 9 commits intoNov 11, 2026
Conversation
…th gitignore Signed-off-by: Hardik Kaurani <[email protected]>
… sample Signed-off-by: Hardik Kaurani <[email protected]>
…uickstart tests Signed-off-by: Hardik Kaurani <[email protected]>
…osts Signed-off-by: Hardik Kaurani <[email protected]>
…erations Signed-off-by: Hardik Kaurani <[email protected]>
… tests Signed-off-by: Hardik Kaurani <[email protected]>
…ests for azure-auth Signed-off-by: Hardik Kaurani <[email protected]>
Signed-off-by: Hardik Kaurani <[email protected]>
Signed-off-by: Hardik Kaurani <[email protected]>
Contributor
Author
|
Hi Vincent Biret (@baywet) — following up on the recent testing improvements across the other quickstarts (like the Dart suite in #9313), I noticed our Go samples were still lacking unit test suites and CI test execution. This PR adds:
All builds and tests run cleanly locally. Whenever you have a chance, I'd appreciate your review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
While reviewing the Go Get Started samples (
get-started/quickstart/goandget-started/azure-auth/go), I noticed that unlike other SDK samples (.NET, Dart, Ruby, PHP), the Go samples currently had no unit test coverage, and the CI workflow (get-started.go.yml) only executed compilation and an un-mocked live run without runninggo test ./....Additionally:
get-started/azure-auth/go/getuser.go, authentication and request errors were logged withfmt.Printfwithout terminating execution, falling through to potential nil-pointer dereferences on*me.GetDisplayName()..gitignorefiles in both Go samples were missing standard Go build and test artifact exclusions (*.exe, binaries,*.test,coverage.out).go-versioninget-started.go.ymlwas set to^1.24, whereasgo.modacross the repository specifiesgo 1.26.0.Changes
Quickstart Unit Tests (
get-started/quickstart/go/main_test.go):TestPostsClient_Initialization: ValidatesPostsClientinstantiation and default base URL (https://jsonplaceholder.typicode.com).TestPostsClient_ToGetRequestInformation: Validates GET method, URL template ({+baseurl}/posts{?title*,userId*}), andAccept: application/jsonheader.TestPostsClient_ToGetRequestInformation_WithQueryParameters: Validates mapping oftitleanduserIdquery parameters intoRequestInformation.TestPostsClient_ToPostRequestInformation: Validates POST request information generation and payload serialization.TestPostsClient_ByPostIdInteger&TestPostsClient_ByPostIdString: Validates GET, PATCH, and DELETE item request builders and path parameter presence without coupling to internal URL-encoded key strings.TestPostModel_PropertiesAndDeserializers: ValidatesPostmodel getters, setters, additional data, and deserializer dictionary completeness.Azure Auth Unit Tests (
get-started/azure-auth/go/getuser_test.go):TestGraphApiClient_Initialization: Validates client creation and base URL (https://graph.microsoft.com/v1.0).TestGraphApiClient_MeToGetRequestInformation: Validatesclient.Me().ToGetRequestInformationmethod, URL template ({+baseurl}/me), and Accept header.Sample Error Handling (
get-started/azure-auth/go/getuser.go):log.Fatalfconsistent withquickstart/go/main.go.CI Workflow Improvements (
.github/workflows/get-started.go.yml):Run Azure auth testsstep (go test -v ./...) tobuild-azure.Run quickstart testsstep (go test -v ./...) tobuild-quickstart.go-versionwithgo.mod(^1.26).Build Configuration:
get-started/quickstart/go/.gitignoreandget-started/azure-auth/go/.gitignore.Verification
All builds and tests pass cleanly locally: