Use FindYAMLWithKey

Signed-off-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
Ettore Di Giacinto
2022-11-28 12:46:15 +00:00
parent 3eccf55e23
commit 06556a31ec
4 changed files with 53 additions and 47 deletions

View File

@@ -36,7 +36,7 @@ bb:
err := ioutil.WriteFile(filepath.Join(d, "test"), []byte(cc), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(d, "b"), []byte(`
fooz:
fooz: "bar"
`), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
@@ -50,14 +50,14 @@ fooz:
err = yaml.Unmarshal(content, &res)
Expect(err).ToNot(HaveOccurred())
hasHeader, _ := config.HasHeader(string(content), "#node-config")
Expect(hasHeader).To(BeTrue())
Expect(res).To(Equal(map[interface{}]interface{}{
"kairos": map[interface{}]interface{}{"network_token": "baz"},
"bb": map[interface{}]interface{}{"nothing": "foo"},
}))
})
hasHeader, _ := config.HasHeader(string(content), "#node-config")
Expect(hasHeader).To(BeTrue(), string(content))
})
})
})