This directory contains all testing-related documentation for HyperSDK.
Total Tests: 340+ tests Daemon API Coverage: 40.8% Status: ✅ All tests passing Last Updated: 2026-01-26
go test ./...
# Generate coverage profile
go test -coverprofile=coverage.out ./daemon/api
# View coverage in terminal
go tool cover -func=coverage.out
# View coverage in browser
go tool cover -html=coverage.out
# API handlers
go test -v ./daemon/api
# Libvirt handlers only
go test -v ./daemon/api -run TestHandle.*Libvirt
# Jobs package
go test -v ./daemon/jobs
go test -v ./daemon/api
✅ Authentication (100%) ✅ Cloud integrations (100%) ✅ Cost tracking (100%) ✅ Helper functions (92-100%) ✅ Libvirt snapshots (85-93%) ✅ Console operations (92-100%)
⚠️ Console info (54.5%) ⚠️ VNC proxy (56.2%) ⚠️ Serial device (46.2%) ⚠️ Clone/template deployment (44.8%)
❌ Backup operations (17-29%) ❌ Batch operations (15%) ❌ Clone operations (0-10%) ❌ Workflow handlers (0%) ❌ Network management (0%)
Create *_test.go file in the same package:
package api
import (
"testing"
"net/http/httptest"
)
func TestHandleNewFeature(t *testing.T) {
server := setupTestBasicServer(t)
// test implementation
}
go test -v ./daemon/api -run TestHandleNewFeature
go test -coverprofile=coverage.out ./daemon/api
go tool cover -func=coverage.out | grep handleNewFeature
Tests run automatically on:
# Install pre-commit hook
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
go test ./...
if [ $? -ne 0 ]; then
echo "Tests failed. Commit aborted."
exit 1
fi
EOF
chmod +x .git/hooks/pre-commit
Increase timeout for slow tests:
go test -timeout 30s ./daemon/api
Run with race detector:
go test -race ./daemon/api
Enable verbose output:
go test -v ./daemon/api 2>&1 | tee test-output.log
When contributing tests:
Test code is licensed under LGPL-3.0-or-later.