mirror of
https://github.com/containers/skopeo.git
synced 2025-06-28 15:47:34 +00:00
Abort in fileFromFixture if a replacement template is not found
This makes the fixture editation more robust against typos or unexpected changes (if the “fixture” comes from third parties, like the OpenShift registry configuration file).
This commit is contained in:
parent
15ce6488dd
commit
cfd1cf6def
@ -159,7 +159,9 @@ func fileFromFixture(c *check.C, inputPath string, edits map[string]string) stri
|
||||
contents, err := ioutil.ReadFile(inputPath)
|
||||
c.Assert(err, check.IsNil)
|
||||
for template, value := range edits {
|
||||
contents = bytes.Replace(contents, []byte(template), []byte(value), -1)
|
||||
updated := bytes.Replace(contents, []byte(template), []byte(value), -1)
|
||||
c.Assert(bytes.Equal(updated, contents), check.Equals, false, check.Commentf("Replacing %s in %#v failed", template, string(contents))) // Verify that the template has matched something and we are not silently ignoring it.
|
||||
contents = updated
|
||||
}
|
||||
|
||||
file, err := ioutil.TempFile("", "policy.json")
|
||||
|
Loading…
Reference in New Issue
Block a user