36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package proc
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestParseLabelString(t *testing.T) {
|
|
got := parseLabelString("com.docker.compose.project=web, com.docker.compose.service=api")
|
|
if got["com.docker.compose.project"] != "web" {
|
|
t.Errorf("project = %q, want web", got["com.docker.compose.project"])
|
|
}
|
|
if got["com.docker.compose.service"] != "api" {
|
|
t.Errorf("service = %q, want api", got["com.docker.compose.service"])
|
|
}
|
|
if len(parseLabelString("")) != 0 {
|
|
t.Error("empty input should yield an empty map")
|
|
}
|
|
}
|
|
|
|
func TestHealthFromStatus(t *testing.T) {
|
|
tests := map[string]string{
|
|
"Up 4 minutes (healthy)": "healthy",
|
|
"Up 2 seconds (unhealthy)": "unhealthy",
|
|
"Up 1 second (health: starting)": "starting",
|
|
"Up 5 minutes": "", // no health check wired
|
|
"Exited (0) 3 minutes ago": "", // parens not at end of status
|
|
}
|
|
for in, want := range tests {
|
|
if got := healthFromStatus(in); got != want {
|
|
t.Errorf("healthFromStatus(%q) = %q, want %q", in, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestParseDockerTime(t *testing.T) {
|
|
if !parseDockerTime("").IsZero() {
|
|
t.Error("empty input should yield the zero time")
|
|
}
|
|
if !parseDockerTime("not a timestamp").IsZero() {
|
|
t.Error("garbage input should yield the zero time")
|
|
}
|
|
got := parseDockerTime("2024-01-02T15:04:05Z")
|
|
if got.IsZero() || got.Year() != 2024 {
|
|
t.Errorf("parseDockerTime(RFC3339) = %v, want a 2024 time", got)
|
|
}
|
|
}
|