core/generate/deploy_builder_test.go
core/generate/deploy_builder_test.goBrowse 1970 files
738 tokens
2,463 bytes
Token encoding: o200k_base
Snapshot 21a254f
← Back to SKILL.md
1package generate2 3import (4 "testing"5 6 "github.com/railwayapp/railpack/core/plan"7 "github.com/stretchr/testify/assert"8)9 10func TestHasIncludeForStep(t *testing.T) {11 tests := []struct {12 name string13 inputs []plan.Layer14 stepName string15 path string16 expected bool17 }{18 {19 name: "empty inputs",20 inputs: []plan.Layer{},21 stepName: "build",22 path: ".",23 expected: false,24 },25 {26 name: "exact match",27 inputs: []plan.Layer{28 {Step: "build", Filter: plan.Filter{Include: []string{"."}}},29 },30 stepName: "build",31 path: ".",32 expected: true,33 },34 {35 name: "dot covers any path",36 inputs: []plan.Layer{37 {Step: "build", Filter: plan.Filter{Include: []string{"."}}},38 },39 stepName: "build",40 path: "/app/dist",41 expected: true,42 },43 {44 name: "any path covers dot",45 inputs: []plan.Layer{46 {Step: "build", Filter: plan.Filter{Include: []string{"/root/.cache", "."}}},47 },48 stepName: "build",49 path: ".",50 expected: true,51 },52 {53 name: "different step name",54 inputs: []plan.Layer{55 {Step: "install", Filter: plan.Filter{Include: []string{"."}}},56 },57 stepName: "build",58 path: ".",59 expected: false,60 },61 {62 name: "specific path match",63 inputs: []plan.Layer{64 {Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},65 },66 stepName: "build",67 path: "/app/node_modules",68 expected: true,69 },70 {71 name: "specific path no match",72 inputs: []plan.Layer{73 {Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},74 },75 stepName: "build",76 path: "/app/dist",77 expected: false,78 },79 {80 name: "specific path does not cover dot",81 inputs: []plan.Layer{82 {Step: "build", Filter: plan.Filter{Include: []string{"/app/node_modules"}}},83 },84 stepName: "build",85 path: ".",86 expected: false,87 },88 }89 90 for _, tt := range tests {91 t.Run(tt.name, func(t *testing.T) {92 builder := NewDeployBuilder()93 builder.DeployInputs = tt.inputs94 result := builder.HasIncludeForStep(tt.stepName, tt.path)95 assert.Equal(t, tt.expected, result)96 })97 }98}99 100func TestHasInputForStep(t *testing.T) {101 builder := NewDeployBuilder()102 builder.DeployInputs = []plan.Layer{103 {Step: "build", Filter: plan.Filter{Include: []string{"apps/landing/.next/standalone"}}},104 }105 106 assert.True(t, builder.HasInputForStep("build"))107 assert.False(t, builder.HasInputForStep("install"))108}109