metis/pkg/plan/plan_env_test.go

40 lines
745 B
Go
Raw Normal View History

package plan
import (
"os"
"testing"
"metis/pkg/inventory"
)
func TestBuildIncludesInjectWhenEnvSet(t *testing.T) {
defer os.Unsetenv("METIS_BOOT_PATH")
os.Setenv("METIS_BOOT_PATH", "/mnt/boot")
inv := &inventory.Inventory{
Classes: []inventory.NodeClass{{
Name: "c1",
Image: "file:///tmp/dummy",
}},
Nodes: []inventory.NodeSpec{{
Name: "n1",
Class: "c1",
Hostname: "n1",
IP: "10.0.0.1",
K3sRole: "agent",
}},
}
p, err := Build(inv, "n1", "/dev/sdz", "/tmp/cache")
if err != nil {
t.Fatalf("build: %v", err)
}
found := false
for _, a := range p.Actions {
if a.Type == "inject" {
found = true
}
}
if !found {
t.Fatalf("expected inject action when METIS_BOOT_PATH set")
}
}