feat: add end-to-end tests for sqlcmd binary (fixes #641)#642
Merged
dlevy-msft-sql merged 2 commits intomicrosoft:mainfrom Jan 27, 2026
Merged
feat: add end-to-end tests for sqlcmd binary (fixes #641)#642dlevy-msft-sql merged 2 commits intomicrosoft:mainfrom
dlevy-msft-sql merged 2 commits intomicrosoft:mainfrom
Conversation
Collaborator
|
these tests should use real queries because we have live connections available in the test pipelines. they can just rely on SQLCMDSERVER being set etc |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive end-to-end tests for the sqlcmd binary that build and execute the actual binary to verify behavior in real-world scenarios. The tests primarily focus on verifying that error conditions (like piped input, missing files, invalid flags) are handled gracefully without panics, especially addressing the regression reported in issue #607.
Changes:
- Adds 8 e2e tests covering help, version, piped input, invalid flags, query execution, and input file handling
- Implements a build-once pattern using
sync.Oncefor efficiency across all test cases - Uses
TestMainfor cleanup of the temporary binary after tests complete
8323fc5 to
2485eeb
Compare
2485eeb to
c7f81e6
Compare
c7f81e6 to
e9e7878
Compare
e9e7878 to
be36d43
Compare
be36d43 to
d0c5f11
Compare
Add e2e tests that build the sqlcmd binary and exercise real-world scenarios: Non-connection tests (always run): - TestE2E_Help: verifies --help flag works - TestE2E_Version: verifies --version flag works - TestE2E_PipedInput_NoPanic: regression test for microsoft#607 (piped input panic) - TestE2E_PipedInput_EmptyInput: empty piped input doesn't panic - TestE2E_InvalidFlag: invalid flags produce helpful errors - TestE2E_QueryFlag_NoServer: -Q flag without server doesn't panic - TestE2E_InputFile_NotFound: missing input file errors gracefully - TestE2E_PipedInput_WithStdinReader: GO batches in piped input work Live connection tests (run when SQLCMDSERVER is set): - TestE2E_PipedInput_LiveConnection: piped SQL with real server - TestE2E_QueryFlag_LiveConnection: -Q flag with real server - TestE2E_InputFile_LiveConnection: -i flag with real server The tests build the binary once and reuse it for all tests. Live connection tests use SQLCMDSERVER, SQLCMDUSER, SQLCMDPASSWORD env vars. Addresses feedback from @shueybubbles in PR microsoft#640.
d0c5f11 to
631801a
Compare
shueybubbles
approved these changes
Jan 27, 2026
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
Adds end-to-end tests that build the sqlcmd binary and exercise real-world
scenarios, as suggested by @shueybubbles in PR #640.
Test Cases
Live Connection Tests (run when SQLCMDSERVER is set)
Implementation Details
Related
Testing
\\�ash
go test -v -run TestE2E ./cmd/modern/...
\\
All 11 tests pass locally (8 always run, 3 skip when no live connection).