Files
pack/core/generate/deploy_builder_test.go
zeekay 7844a60aff refactor(pack): modernize to github.com/hanzoai/pack and remove upstream branding
- Migrate module path to github.com/hanzoai/pack across all Go packages
- Remove legacy upstream docs and competitor brand references
- Modernize LLM.md and mise.toml for pristine Hanzo Pack builder
2026-09-04 00:40:42 -07:00

109 lines
2.4 KiB
Go

package generate
import (
"testing"
"github.com/hanzoai/pack/core/plan"
"github.com/stretchr/testify/assert"
)
func TestHasIncludeForStep(t *testing.T) {
tests := []struct {
name string
inputs []plan.Layer
stepName string
path string
expected bool
}{
{
name: "empty inputs",
inputs: []plan.Layer{},
stepName: "build",
path: ".",
expected: false,
},
{
name: "exact match",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"."}}},
},
stepName: "build",
path: ".",
expected: true,
},
{
name: "dot covers any path",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"."}}},
},
stepName: "build",
path: "/app/dist",
expected: true,
},
{
name: "any path covers dot",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"/root/.cache", "."}}},
},
stepName: "build",
path: ".",
expected: true,
},
{
name: "different step name",
inputs: []plan.Layer{
{Step: "install", Filter: plan.Filter{Include: []string{"."}}},
},
stepName: "build",
path: ".",
expected: false,
},
{
name: "specific path match",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},
},
stepName: "build",
path: "/app/node_modules",
expected: true,
},
{
name: "specific path no match",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},
},
stepName: "build",
path: "/app/dist",
expected: false,
},
{
name: "specific path does not cover dot",
inputs: []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},
},
stepName: "build",
path: ".",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
builder := NewDeployBuilder()
builder.DeployInputs = tt.inputs
result := builder.HasIncludeForStep(tt.stepName, tt.path)
assert.Equal(t, tt.expected, result)
})
}
}
func TestHasInputForStep(t *testing.T) {
builder := NewDeployBuilder()
builder.DeployInputs = []plan.Layer{
{Step: "build", Filter: plan.Filter{Include: []string{"apps/landing/.next/standalone"}}},
}
assert.True(t, builder.HasInputForStep("build"))
assert.False(t, builder.HasInputForStep("install"))
}