Files
Charon/backend/internal/api/handlers/conversion_test.go
GitHub Actions 2a6175a97e feat: Implement CrowdSec toggle fix validation and documentation updates
- Added QA summary report for CrowdSec toggle fix validation, detailing test results, code quality audit, and recommendations for deployment.
- Updated existing QA report to reflect the new toggle fix validation status and testing cycle.
- Enhanced security documentation to explain the persistence of CrowdSec across container restarts and troubleshooting steps for common issues.
- Expanded troubleshooting guide to address scenarios where CrowdSec does not start after a container restart, including diagnosis and solutions.
2025-12-15 07:30:36 +00:00

54 lines
1.1 KiB
Go

package handlers
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSafeIntToUint(t *testing.T) {
t.Run("ValidPositive", func(t *testing.T) {
val, ok := safeIntToUint(42)
assert.True(t, ok)
assert.Equal(t, uint(42), val)
})
t.Run("Zero", func(t *testing.T) {
val, ok := safeIntToUint(0)
assert.True(t, ok)
assert.Equal(t, uint(0), val)
})
t.Run("Negative", func(t *testing.T) {
val, ok := safeIntToUint(-1)
assert.False(t, ok)
assert.Equal(t, uint(0), val)
})
}
func TestSafeFloat64ToUint(t *testing.T) {
t.Run("ValidPositive", func(t *testing.T) {
val, ok := safeFloat64ToUint(42.0)
assert.True(t, ok)
assert.Equal(t, uint(42), val)
})
t.Run("Zero", func(t *testing.T) {
val, ok := safeFloat64ToUint(0.0)
assert.True(t, ok)
assert.Equal(t, uint(0), val)
})
t.Run("Negative", func(t *testing.T) {
val, ok := safeFloat64ToUint(-1.0)
assert.False(t, ok)
assert.Equal(t, uint(0), val)
})
t.Run("NotInteger", func(t *testing.T) {
val, ok := safeFloat64ToUint(42.5)
assert.False(t, ok)
assert.Equal(t, uint(0), val)
})
}