This project has comprehensive test coverage for all major components of the PROFFIX REST API wrapper.
go test -v ./...go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...go tool cover -html=coverage.txtgo test -v -run TestClient_Requests ./proffixrestclient_test.go- Core client functionality (POST, PUT, GET, DELETE, Login, Logout)advanced_test.go- Advanced features (PATCH, ServiceLogin, concurrent access, options)batch_test.go- Batch request handlingsync_batch_test.go- Synchronous batch operationslist_test.go- List generation and retrievalcheck_test.go- API health checkshelper_test.go- Helper functions (GetFiltererCount, ReaderToString, etc.)error_test.go- Error handling and PxError typestools_test.go- Utility functions (time conversion, ID extraction)
- ✅ HTTP Methods: GET, POST, PUT, PATCH, DELETE
- ✅ Authentication: Login, Logout, ServiceLogin
- ✅ Session Management: GetPxSessionId, updatePxSessionId
- ✅ Batch Operations: GetBatch, SyncBatch
- ✅ File Operations: File upload/download
- ✅ List Generation: GetList
- ✅ GetFiltererCount - Parse metadata from headers
- ✅ ReaderToString/ReaderToByte - Stream conversions
- ✅ GetMaps/GetMap - JSON parsing
- ✅ WriteFile - File writing
- ✅ GetUsedLicences - License calculation
- ✅ GetFileTokens - File token extraction
- ✅ PxError creation and formatting
- ✅ isInvalidFields / isNotFound type checks
- ✅ Error messages with field details
- ✅ Default error messages for edge cases
- ✅ Nil readers
- ✅ Empty headers
- ✅ Invalid URLs
- ✅ Concurrent access
- ✅ Multiple sequential requests
- ✅ Session ID updates
The project uses GitHub Actions for continuous integration with the following jobs:
- Matrix Testing: Tests against Go versions 1.20, 1.21, 1.22, 1.23
- Race Detection: Runs with
-raceflag to detect data races - Coverage: Generates coverage reports and uploads to Codecov
- Dependency Verification: Ensures
go.modandgo.sumare in sync
- golangci-lint: Runs comprehensive linting with 19+ linters
- Timeout: 5 minutes to ensure thorough analysis
- Configuration: Uses
.golangci.ymlfor custom rules
- Dependencies: Requires test and lint jobs to pass
- Builds: Compiles main package and cmd/proffix-rest
- Examples: Builds all example applications
golangci-lint run --timeout=5m- errcheck - Check for unchecked errors
- gosimple - Simplify code
- govet - Vet examines Go source code
- ineffassign - Detect ineffectual assignments
- staticcheck - Static analysis
- unused - Check for unused code
- gofmt - Format checking
- goimports - Import formatting
- misspell - Spell checking
- unconvert - Remove unnecessary conversions
- unparam - Detect unused parameters
- bodyclose - Check HTTP response body closes
- gosec - Security issues
- prealloc - Preallocate slices
- gocritic - Comprehensive checks
- revive - Fast linter
- nilness - Detect nil pointer dereferences
- copylocks - Detect mutex copies
Tests use the PROFFIX public demo server by default:
- URL:
https://portal.proffix.net:11011 - Database:
DEMODB - User:
Gast
For private testing, set:
PXDEMO_URLPXDEMO_USERPXDEMO_PASSWORDPXDEMO_DATABASEPXDEMO_KEY
&Options{
Key: "...",
VerifySSL: false,
Autologout: false,
VolumeLicence: true,
}- Always use context: Pass
context.Background()or custom context - Cleanup resources: Use
defer pxrest.Logout(ctx)after connection - Check errors: Always verify error returns
- Close readers: Close
io.ReadCloserwhen done - Test isolation: Each test should be independent
- Check if demo server is accessible
- Verify network connectivity
- Ensure credentials are valid
- Run with
-coverprofile=coverage.txt - Ensure all packages are tested with
./...
- Run
golangci-lint runlocally first - Check
.golangci.ymlfor configuration - Some test files exclude certain linters
When adding new features:
- Write tests first (TDD approach)
- Ensure tests pass locally
- Run linter before committing
- Maintain or improve coverage
- Add test documentation for complex scenarios