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

Removes unneeded unit tests from detect #141

Merged
merged 1 commit into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gobuild_test

import (
"errors"
"path/filepath"
"testing"

gobuild "github.com/paketo-buildpacks/go-build"
Expand Down Expand Up @@ -53,72 +52,6 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Expect(parser.ParseCall.Receives.WorkingDir).To(Equal(workingDir))
})

context("when flags are set in the build configuration", func() {
it.Before(func() {
parser.ParseCall.Returns.BuildConfiguration.Flags = []string{"-some-flag=flag"}
})

it("adds flags to the build plan", func() {
result, err := detect(packit.DetectContext{
WorkingDir: workingDir,
})
Expect(err).NotTo(HaveOccurred())
Expect(result.Plan).To(Equal(packit.BuildPlan{
Requires: []packit.BuildPlanRequirement{{
Name: "go",
Metadata: map[string]interface{}{
"build": true,
},
}},
}))
})
})

context("when import path are set in the build configuration", func() {
it.Before(func() {
parser.ParseCall.Returns.BuildConfiguration.ImportPath = "./some/path"
})

it("adds import-path to the build plan", func() {
result, err := detect(packit.DetectContext{
WorkingDir: workingDir,
})
Expect(err).NotTo(HaveOccurred())
Expect(result.Plan).To(Equal(packit.BuildPlan{
Requires: []packit.BuildPlanRequirement{{
Name: "go",
Metadata: map[string]interface{}{
"build": true,
},
}},
}))
})
})

context("when there are multiple targets", func() {
it.Before(func() {
parser.ParseCall.Returns.BuildConfiguration.Targets = []string{
filepath.Join(workingDir, "first"),
filepath.Join(workingDir, "second"),
}
})

it("detects only if all targets have go source files", func() {
result, err := detect(packit.DetectContext{
WorkingDir: workingDir,
})
Expect(err).NotTo(HaveOccurred())
Expect(result.Plan).To(Equal(packit.BuildPlan{
Requires: []packit.BuildPlanRequirement{{
Name: "go",
Metadata: map[string]interface{}{
"build": true,
},
}},
}))
})
})

context("when there are no *.go files in the working directory", func() {
it.Before(func() {
parser.ParseCall.Returns.Error = errors.New("no *.go files found")
Expand Down