Release a whole-file hold once the file is declared written into (hq ADR 0102)
This commit is contained in:
@@ -281,3 +281,24 @@ func TestAListTheMeshCreatedGoesWhenEmptied(t *testing.T) {
|
||||
t.Errorf("the key the mesh created was not removed: %v", o)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHoldFromAWholeFileDoesNotKeepOutAnIntoWrite(t *testing.T) {
|
||||
// Declared whole before, the runtime's file was held; declared into now, it is written into.
|
||||
path := filepath.Join(t.TempDir(), "daemon.json")
|
||||
_ = os.WriteFile(path, []byte(machinesOwn), 0o644)
|
||||
known := store.State{Held: []store.Held{{ID: "networking.registry-trust", Module: "networking",
|
||||
Kind: "file", Target: path}}}
|
||||
d := adopted(t, `{"taken":[],"untaken":{"networking":["networking.registry-trust"]}}`,
|
||||
fmt.Sprintf(`{"id":"networking.registry-trust","type":"file","path":%q,"into":"json","content":%q}`,
|
||||
path, `{"insecure-registries":["10.42.0.1:5000"]}`))
|
||||
report, state := applyAdopted(t, d, known, &machine{}, t.TempDir())
|
||||
if got := outcomeOf(report, "networking.registry-trust").Action; got != "updated" {
|
||||
t.Errorf("the file was %q, not written into", got)
|
||||
}
|
||||
if len(state.Held) != 0 {
|
||||
t.Errorf("the old hold outlived the into declaration: %+v", state.Held)
|
||||
}
|
||||
if fmt.Sprint(readObject(t, path)["insecure-registries"]) != "[192.0.2.7:5000 10.42.0.1:5000]" {
|
||||
t.Errorf("the mesh's member was not written in: %v", readObject(t, path))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user