All checks were successful
Check / check (pull_request) Successful in 3m24s
- Add cpu_limit (REAL) and memory_limit (INTEGER) columns to apps table via migration 007 - Add CPULimit and MemoryLimit fields to App model with full CRUD support - Add resource limits fields to app edit form with human-friendly memory input (e.g. 256m, 1g, 512k) - Pass CPU and memory limits to Docker container creation via NanoCPUs and Memory host config fields - Extract Docker container creation helpers (buildEnvSlice, buildMounts, buildResources) for cleaner code - Add formatMemoryBytes template function for display - Add comprehensive tests for parsing, formatting, model persistence, and container options
32 lines
639 B
Go
32 lines
639 B
Go
package docker //nolint:testpackage // tests unexported cpuLimitToNanoCPUs
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCpuLimitToNanoCPUs(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
cpuLimit float64
|
|
expected int64
|
|
}{
|
|
{"one core", 1.0, 1_000_000_000},
|
|
{"half core", 0.5, 500_000_000},
|
|
{"two cores", 2.0, 2_000_000_000},
|
|
{"quarter core", 0.25, 250_000_000},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := cpuLimitToNanoCPUs(tt.cpuLimit)
|
|
if got != tt.expected {
|
|
t.Errorf("cpuLimitToNanoCPUs(%v) = %d, want %d", tt.cpuLimit, got, tt.expected)
|
|
}
|
|
})
|
|
}
|
|
}
|