Skip to content

Commit

Permalink
Merge pull request #86 from jghiloni/issue-85
Browse files Browse the repository at this point in the history
Add struct tag to Buildpack.Path field
  • Loading branch information
samj1912 committed Nov 4, 2021
2 parents bc6e6ca + b2b6b4b commit 8c10662
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buildpack.go
Expand Up @@ -91,7 +91,7 @@ type Buildpack struct {
Info BuildpackInfo `toml:"buildpack"`

// Path is the path to the buildpack.
Path string
Path string `toml:"-"`

// Stacks is the collection of stacks supported by the buildpack.
Stacks []BuildpackStack `toml:"stacks"`
Expand Down
50 changes: 50 additions & 0 deletions buildpack_test.go
@@ -0,0 +1,50 @@
/*
* Copyright 2018-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package libcnb_test

import (
"bytes"
"testing"

"github.com/BurntSushi/toml"
"github.com/buildpacks/libcnb"
"github.com/sclevine/spec"

. "github.com/onsi/gomega"
)

func testBuildpackTOML(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
)

it("does not serialize the Path field", func() {
bp := libcnb.Buildpack{
API: "0.6",
Info: libcnb.BuildpackInfo{
ID: "test-buildpack/sample",
Name: "sample",
},
Path: "../buildpack",
}

output := &bytes.Buffer{}

Expect(toml.NewEncoder(output).Encode(bp)).To(Succeed())
Expect(output.String()).NotTo(Or(ContainSubstring("Path = "), ContainSubstring("path = ")))
})
}
1 change: 1 addition & 0 deletions init_test.go
Expand Up @@ -33,5 +33,6 @@ func TestUnit(t *testing.T) {
suite("Main", testMain)
suite("Platform", testPlatform)
suite("ExecD", testExecD)
suite("BuildpackTOML", testBuildpackTOML)
suite.Run(t)
}

0 comments on commit 8c10662

Please sign in to comment.