(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestBuildStandardNpmEngineInstallSteps(t *testing.T) { |
| 59 | tests := []struct { |
| 60 | name string |
| 61 | workflowData *WorkflowData |
| 62 | expectedSteps int // Number of steps expected (Node.js setup + npm install) |
| 63 | expectedInStep string |
| 64 | }{ |
| 65 | { |
| 66 | name: "with default version", |
| 67 | workflowData: &WorkflowData{}, |
| 68 | expectedSteps: 2, // Node.js setup + npm install |
| 69 | expectedInStep: string(constants.DefaultCopilotVersion), |
| 70 | }, |
| 71 | { |
| 72 | name: "with custom version from engine config", |
| 73 | workflowData: &WorkflowData{ |
| 74 | EngineConfig: &EngineConfig{ |
| 75 | Version: "1.2.3", |
| 76 | }, |
| 77 | }, |
| 78 | expectedSteps: 2, |
| 79 | expectedInStep: "1.2.3", |
| 80 | }, |
| 81 | { |
| 82 | name: "with empty version in engine config (use default)", |
| 83 | workflowData: &WorkflowData{ |
| 84 | EngineConfig: &EngineConfig{ |
| 85 | Version: "", |
| 86 | }, |
| 87 | }, |
| 88 | expectedSteps: 2, |
| 89 | expectedInStep: string(constants.DefaultCopilotVersion), |
| 90 | }, |
| 91 | } |
| 92 | |
| 93 | for _, tt := range tests { |
| 94 | t.Run(tt.name, func(t *testing.T) { |
| 95 | steps := BuildStandardNpmEngineInstallSteps( |
| 96 | "@github/copilot", |
| 97 | string(constants.DefaultCopilotVersion), |
| 98 | "Install GitHub Copilot CLI", |
| 99 | "copilot", |
| 100 | tt.workflowData, |
| 101 | ) |
| 102 | |
| 103 | if len(steps) != tt.expectedSteps { |
| 104 | t.Errorf("Expected %d steps, got %d", tt.expectedSteps, len(steps)) |
| 105 | } |
| 106 | |
| 107 | // Verify that the expected version appears in the steps |
| 108 | found := false |
| 109 | for _, step := range steps { |
| 110 | for _, line := range step { |
| 111 | if strings.Contains(line, tt.expectedInStep) { |
| 112 | found = true |
| 113 | break |
| 114 | } |
| 115 | } |
nothing calls this directly
no test coverage detected