Resolve stats, thumbnails, window actions, SSH, affinity and diagnostic bundles through VMRef-aware VM information. Isolate caches, SSH aliases and frontend pollers for same-name VMs while preserving macOS defaults.
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package app
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/Nwflower/reims-go/internal/config"
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
)
|
|
|
|
func TestSameNamedVMMemoryStatesUseDriverQualifiedKeys(t *testing.T) {
|
|
a := &App{
|
|
transitions: map[string]string{}, pendingChanges: map[string][]PendingChange{},
|
|
diskPaths: map[string]cachedDiskPath{}, procSamples: map[string]host.ProcessSample{},
|
|
}
|
|
aKey := vmKeyForDriver("test.driver.a", "shared")
|
|
bKey := vmKeyForDriver("test.driver.b", "shared")
|
|
if aKey == bKey {
|
|
t.Fatal("same-named VMs share a key")
|
|
}
|
|
a.transitions[aKey] = "starting"
|
|
a.pendingChanges[bKey] = []PendingChange{{Field: "memory"}}
|
|
a.diskPaths[aKey] = cachedDiskPath{path: "a", at: time.Now()}
|
|
a.procSamples[bKey] = host.ProcessSample{}
|
|
if len(a.transitions) != 1 || a.transitions[bKey] != "" {
|
|
t.Fatalf("transitions = %+v", a.transitions)
|
|
}
|
|
if len(a.pendingChanges[aKey]) != 0 || len(a.pendingChanges[bKey]) != 1 {
|
|
t.Fatalf("pending = %+v", a.pendingChanges)
|
|
}
|
|
if len(a.diskPaths) != 1 || len(a.procSamples) != 1 {
|
|
t.Fatal("driver-qualified cache keys collided")
|
|
}
|
|
a.cfg = &config.Config{DataRoot: t.TempDir()}
|
|
if a.thumbPathForDriver("test.driver.a", "shared") == a.thumbPathForDriver("test.driver.b", "shared") {
|
|
t.Fatal("same-named VMs share a thumbnail path")
|
|
}
|
|
if got := a.thumbPath("shared"); got != a.thumbPathForDriver("", "shared") {
|
|
t.Fatal("default thumbnail path changed")
|
|
}
|
|
}
|