Add comprehensive unit tests and improve example documentation #136
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
This PR significantly improves the test coverage and documentation for libsql-client-go by adding comprehensive unit tests and enhancing the examples.
Changes
Test Coverage Improvements
Added extensive unit tests across multiple packages, bringing coverage from near-zero to production-ready levels:
New Test Files
libsql/sql_test.go (737 lines)
NewConnector
with various URL schemes and optionsWithAuthToken
,WithTls
,WithProxy
,WithSchemaDb
)Contains
,Index
,extractJwt
,extractTls
)libsql/internal/http/shared/params_test.go (470 lines)
ParseStatement
andParseStatementAndArgs
functionsLen
,MarshalJSON
,Type
)libsql/internal/http/shared/result_test.go (71 lines)
LastInsertId
andRowsAffected
methodslibsql/internal/http/shared/rows_test.go (305 lines)
libsql/internal/http/hranaV2/hranaV2_test.go (617 lines)
libsql/internal/hrana/stream_request_test.go (238 lines)
ExecuteStream
,BatchStream
, etc.)libsql/internal/hrana/batch_test.go (128 lines)
Total Test Coverage
Documentation Improvements
Enhanced Example Code (
examples/sql/counter/main.go
)?
,?N
,:name
,@name
,$name
)New Examples README (
examples/README.md
)Comprehensive guide covering:
Testing
All new tests pass successfully:
go test ./libsql/...
Coverage reports are available via:
go test -cover ./libsql/...
Benefits
Checklist