fix(build): reject nil release workflow medium
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
a2e3c3d6a2
commit
e01c88e39b
2 changed files with 13 additions and 1 deletions
|
|
@ -28,11 +28,15 @@ const DefaultReleaseWorkflowFileName = "release.yml"
|
|||
// build.WriteReleaseWorkflow(io.Local, "ci/release.yml") // writes ./ci/release.yml under the project root
|
||||
// build.WriteReleaseWorkflow(io.Local, "/tmp/repo/.github/workflows/release.yml") // writes the absolute path unchanged
|
||||
func WriteReleaseWorkflow(medium io_interface.Medium, outputPath string) error {
|
||||
if medium == nil {
|
||||
return coreerr.E("build.WriteReleaseWorkflow", "filesystem medium is required", nil)
|
||||
}
|
||||
|
||||
if outputPath == "" {
|
||||
outputPath = DefaultReleaseWorkflowPath
|
||||
}
|
||||
|
||||
if medium != nil && (isDirectoryLikePath(outputPath) || medium.IsDir(outputPath)) {
|
||||
if isDirectoryLikePath(outputPath) || medium.IsDir(outputPath) {
|
||||
outputPath = ax.Join(outputPath, DefaultReleaseWorkflowFileName)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,14 @@ func TestWorkflow_WriteReleaseWorkflow_Good(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestWorkflow_WriteReleaseWorkflow_Bad(t *testing.T) {
|
||||
t.Run("rejects a nil filesystem medium", func(t *testing.T) {
|
||||
err := WriteReleaseWorkflow(nil, "")
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "filesystem medium is required")
|
||||
})
|
||||
}
|
||||
|
||||
func TestWorkflow_ReleaseWorkflowPath_Good(t *testing.T) {
|
||||
assert.Equal(t, "/tmp/project/.github/workflows/release.yml", ReleaseWorkflowPath("/tmp/project"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue