Skip to content

Commit

Permalink
Merge pull request #19 from paketo-buildpacks/indented-toml
Browse files Browse the repository at this point in the history
Indented TOML
  • Loading branch information
ekcasey authored Nov 3, 2020
2 parents 34ecd2a + 23b1fe6 commit 591e6a4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion carton/buildpack_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
BuildpackDependencyPattern = `(?m)(.*id[\s]+=[\s]+"%s"\n.*\nversion[\s]+=[\s]+")%s("\nuri[\s]+=[\s]+").*("\nsha256[\s]+=[\s]+").*(".*)`
BuildpackDependencyPattern = `(?m)([\s]*.*id[\s]+=[\s]+"%s"\n.*\n[\s]*version[\s]+=[\s]+")%s("\n[\s]*uri[\s]+=[\s]+").*("\n[\s]*sha256[\s]+=[\s]+").*(".*)`
BuildpackDependencySubstitution = "${1}%s${2}%s${3}%s${4}"
)

Expand Down
47 changes: 38 additions & 9 deletions carton/buildpack_dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ func testBuildpackDependency(t *testing.T, context spec.G, it spec.S) {

f, err := ioutil.TempFile("", "carton-buildpack-dependency")
Expect(err).NotTo(HaveOccurred())

_, err = f.WriteString(`id = "test-id"
name = "Test Name"
version = "test-version-1"
uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
`)
Expect(err).To(Succeed())
Expect(f.Close()).To(Succeed())
path = f.Name()
})
Expand All @@ -63,6 +54,14 @@ stacks = [ "test-stack" ]
})

it("updates dependency", func() {
Expect(ioutil.WriteFile(path, []byte(`id = "test-id"
name = "Test Name"
version = "test-version-1"
uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
`), 0644)).To(Succeed())

d := carton.BuildpackDependency{
BuildpackPath: path,
ID: "test-id",
Expand All @@ -82,4 +81,34 @@ sha256 = "test-sha256-2"
stacks = [ "test-stack" ]
`)))
})

it("updates indented dependency", func() {
Expect(ioutil.WriteFile(path, []byte(` id = "test-id"
name = "Test Name"
version = "test-version-1"
uri = "test-uri-1"
sha256 = "test-sha256-1"
stacks = [ "test-stack" ]
`), 0644)).To(Succeed())

d := carton.BuildpackDependency{
BuildpackPath: path,
ID: "test-id",
SHA256: "test-sha256-2",
URI: "test-uri-2",
Version: "test-version-2",
VersionPattern: `test-version-[\d]`,
}

d.Update(carton.WithExitHandler(exitHandler))

Expect(ioutil.ReadFile(path)).To(Equal([]byte(` id = "test-id"
name = "Test Name"
version = "test-version-2"
uri = "test-uri-2"
sha256 = "test-sha256-2"
stacks = [ "test-stack" ]
`)))
})

}

0 comments on commit 591e6a4

Please sign in to comment.