package main // The module's shape (novox/hq to-be 42 Phase 1, research 027): two files written whole and the // time zone as a step of its own binary — never a symbolic link written by the mesh (ADR 0012), // never an action (ADR 0005). import ( "strings" "testing" ) func TestTheFilesSayWhatTheToolsCompareAgainst(t *testing.T) { m := manifest(t) if m.Module != "localization" || m.Version != "1" { t.Fatalf("%s %s", m.Module, m.Version) } locale := m.resource(t, "locale") if locale["path"] != "/etc/locale.conf" || locale["into"] != nil || !strings.Contains(locale["content"].(string), "\nLANG="+MeshLang+"\n") { t.Fatalf("locale: %v", locale) } keymap := m.resource(t, "keymap") if keymap["path"] != "/etc/vconsole.conf" || !strings.Contains(keymap["content"].(string), "\nKEYMAP="+MeshKeymap+"\n") { t.Fatalf("keymap: %v", keymap) } for _, r := range []resource{locale, keymap} { var settings []string for _, l := range strings.Split(r["content"].(string), "\n") { if l != "" && !strings.HasPrefix(l, "#") { settings = append(settings, l) } } if len(settings) != 1 { t.Fatalf("%v says one thing: %v", r["id"], settings) } } } func TestTheTimeZoneIsAStepOfTheModulesOwnBinaryRunAsRoot(t *testing.T) { m := manifest(t) step := m.resource(t, "time-zone") if step["type"] != "process" || step["run-once"] != true || step["artifact"] != "tools" || step["user"] != nil { t.Fatalf("step: %v", step) } run := step["run"].([]any) if len(run) != 3 || run[0] != "./"+binaryName || run[1] != "set-time-zone" || run[2] != MeshZone { t.Fatalf("run: %v", run) } for _, r := range m.Resources { if r["type"] == "action" || r["path"] == "/etc/localtime" { t.Fatalf("%v: the zone is never written by the mesh", r["id"]) } } }