34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCloudInitUsesRetryingBootstrap(t *testing.T) {
|
|
got := cloudInit(baseConfig(), "ssh-ed25519 test")
|
|
for _, want := range []string{
|
|
"package_update: false",
|
|
"bash -euxo pipefail <<'BOOT'",
|
|
"Acquire::Retries \"8\";",
|
|
"retry apt-get update",
|
|
"retry apt-get install -y --no-install-recommends openssh-server ca-certificates curl git rsync jq",
|
|
"curl --version >/dev/null",
|
|
"test -f /var/lib/crabbox/bootstrapped",
|
|
"test -w /work/crabbox",
|
|
"touch /var/lib/crabbox/bootstrapped",
|
|
} {
|
|
if !strings.Contains(got, want) {
|
|
t.Fatalf("cloudInit() missing %q", want)
|
|
}
|
|
}
|
|
if strings.Contains(got, "\npackages:\n") {
|
|
t.Fatal("cloudInit() must not use cloud-init's one-shot packages module")
|
|
}
|
|
for _, notWant := range []string{"go version", "golang-go", "go.dev/dl/go", "/usr/local/go", "node --version", "pnpm --version", "docker --version", "build-essential", "docker.io", "corepack"} {
|
|
if strings.Contains(got, notWant) {
|
|
t.Fatalf("cloudInit() should not install project language runtime %q", notWant)
|
|
}
|
|
}
|
|
}
|