Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add struct tag to Buildpack.Path field #86

Merged
merged 3 commits into from Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(ContainSubstring("ath = ")) // match on path and Path
jghiloni marked this conversation as resolved.
Show resolved Hide resolved
})
}
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)
}