mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 03:20:11 +00:00
- Add persistent volume mounts for Go/npm caches (faster rebuilds) - Add shell config with helpful aliases and custom prompt - Add comprehensive devcontainer documentation - Add pre-commit hooks for Go formatting and linting - Use go-version-file in CI workflows instead of hardcoded versions - Simplify docker compose commands with --wait flag - Add gitignore entries for devcontainer auth files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
package monitoring
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/rcourtman/pulse-go-rewrite/internal/models"
|
|
"github.com/rcourtman/pulse-go-rewrite/pkg/proxmox"
|
|
)
|
|
|
|
type stubPVEClientContainerMetadata struct {
|
|
stubPVEClient
|
|
|
|
config map[string]interface{}
|
|
|
|
configCalls int
|
|
statusCalls int
|
|
}
|
|
|
|
func (s *stubPVEClientContainerMetadata) GetContainerConfig(ctx context.Context, node string, vmid int) (map[string]interface{}, error) {
|
|
s.configCalls++
|
|
return s.config, nil
|
|
}
|
|
|
|
func (s *stubPVEClientContainerMetadata) GetContainerStatus(ctx context.Context, node string, vmid int) (*proxmox.Container, error) {
|
|
s.statusCalls++
|
|
return nil, nil
|
|
}
|
|
|
|
func TestEnrichContainerMetadata_DetectsOCIForStoppedContainer(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
monitor := &Monitor{}
|
|
client := &stubPVEClientContainerMetadata{
|
|
config: map[string]interface{}{
|
|
"entrypoint": "/bin/sh",
|
|
"ostype": "unmanaged",
|
|
"cmode": "console",
|
|
"lxc": "lxc.signal.halt: SIGTERM",
|
|
},
|
|
}
|
|
|
|
container := &models.Container{
|
|
VMID: 300,
|
|
Name: "oci-alpine",
|
|
Status: "stopped",
|
|
Type: "lxc",
|
|
}
|
|
|
|
monitor.enrichContainerMetadata(context.Background(), client, "delly", "delly", container)
|
|
|
|
if client.configCalls != 1 {
|
|
t.Fatalf("expected 1 config call, got %d", client.configCalls)
|
|
}
|
|
if client.statusCalls != 0 {
|
|
t.Fatalf("expected 0 status calls for stopped container, got %d", client.statusCalls)
|
|
}
|
|
if !container.IsOCI {
|
|
t.Fatalf("expected container.IsOCI true, got false")
|
|
}
|
|
if container.Type != "oci" {
|
|
t.Fatalf("expected container.Type oci, got %q", container.Type)
|
|
}
|
|
}
|