The manifest gains the file resource toolchain-wait (content ${config:toolchain-wait-minutes}) and names its path in
MESH_BUILDER_TOOLCHAIN_WAIT_FILE; main.go's toolchainWaitOf reads it.
Builds: design 47 G §672, A-71 (G-20)
Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// A-71: the toolchain wait's setting is read at the start from the file the manifest declares, never from the environment.
|
|
func TestToolchainWaitIsReadFromItsFile(t *testing.T) {
|
|
dir := t.TempDir()
|
|
n := 0
|
|
file := func(content string) string {
|
|
n++
|
|
p := filepath.Join(dir, "w"+string(rune('a'+n)))
|
|
if err := os.WriteFile(p, []byte(content), 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return p
|
|
}
|
|
for _, c := range []struct {
|
|
name, path string
|
|
want time.Duration
|
|
bad bool
|
|
}{
|
|
{"no file named", "", defaultToolchainWait, false},
|
|
{"file absent", filepath.Join(dir, "absent"), defaultToolchainWait, false},
|
|
{"empty", file(" \n"), defaultToolchainWait, false},
|
|
{"minutes", file("15\n"), 15 * time.Minute, false},
|
|
{"not a number", file("soon"), 0, true},
|
|
{"zero", file("0"), 0, true},
|
|
} {
|
|
got, err := toolchainWaitOf(c.path)
|
|
if (err != nil) != c.bad || got != c.want {
|
|
t.Errorf("%s: %v, %v; want %v, error %v", c.name, got, err, c.want, c.bad)
|
|
}
|
|
}
|
|
}
|