mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
28 lines
677 B
Go
28 lines
677 B
Go
package install
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestToFirstbootConfigIncludesInstallCallback(t *testing.T) {
|
|
const url = "http://192.168.1.12/boot/done?mac=aa:bb:cc:dd:ee:ff"
|
|
t.Setenv("SPINIFEX_INSTALL_CALLBACK", url)
|
|
|
|
cfg := &Config{Hostname: "node1"}
|
|
fb := cfg.toFirstbootConfig()
|
|
if fb.InstallCallback != url {
|
|
t.Errorf("InstallCallback = %q, want %q", fb.InstallCallback, url)
|
|
}
|
|
}
|
|
|
|
func TestToFirstbootConfigEmptyCallbackWhenEnvUnset(t *testing.T) {
|
|
os.Unsetenv("SPINIFEX_INSTALL_CALLBACK")
|
|
|
|
cfg := &Config{Hostname: "node1"}
|
|
fb := cfg.toFirstbootConfig()
|
|
if fb.InstallCallback != "" {
|
|
t.Errorf("InstallCallback = %q, want empty", fb.InstallCallback)
|
|
}
|
|
}
|