diff --git a/integration/copy_test.go b/integration/copy_test.go index d4bd3b5d..4218bbc2 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "fmt" "io/ioutil" "log" @@ -80,26 +79,6 @@ func (s *CopySuite) TearDownSuite(c *check.C) { } } -// fileFromFixtureFixture applies edits to inputPath and returns a path to the temporary file. -// Callers should defer os.Remove(the_returned_path) -func fileFromFixture(c *check.C, inputPath string, edits map[string]string) string { - contents, err := ioutil.ReadFile(inputPath) - c.Assert(err, check.IsNil) - for template, value := range edits { - contents = bytes.Replace(contents, []byte(template), []byte(value), -1) - } - - file, err := ioutil.TempFile("", "policy.json") - c.Assert(err, check.IsNil) - path := file.Name() - - _, err = file.Write(contents) - c.Assert(err, check.IsNil) - err = file.Close() - c.Assert(err, check.IsNil) - return path -} - func (s *CopySuite) TestCopyFailsWithManifestList(c *check.C) { assertSkopeoFails(c, ".*can not copy docker://estesp/busybox:latest: manifest contains multiple images.*", "copy", "docker://estesp/busybox:latest", "dir:somedir") } diff --git a/integration/utils.go b/integration/utils.go index c58afeed..51eff3c5 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -1,7 +1,9 @@ package main import ( + "bytes" "io" + "io/ioutil" "net" "os/exec" "strings" @@ -150,3 +152,23 @@ func modifyEnviron(env []string, name, value string) []string { } return append(res, prefix+value) } + +// fileFromFixtureFixture applies edits to inputPath and returns a path to the temporary file. +// Callers should defer os.Remove(the_returned_path) +func fileFromFixture(c *check.C, inputPath string, edits map[string]string) string { + contents, err := ioutil.ReadFile(inputPath) + c.Assert(err, check.IsNil) + for template, value := range edits { + contents = bytes.Replace(contents, []byte(template), []byte(value), -1) + } + + file, err := ioutil.TempFile("", "policy.json") + c.Assert(err, check.IsNil) + path := file.Name() + + _, err = file.Write(contents) + c.Assert(err, check.IsNil) + err = file.Close() + c.Assert(err, check.IsNil) + return path +}