MCPcopy Create free account
hub / github.com/github/gh-aw / TestInstallStepsContainNodeSetup

Function TestInstallStepsContainNodeSetup

pkg/workflow/threat_detection_test.go:2042–2090  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2040}
2041
2042func TestInstallStepsContainNodeSetup(t *testing.T) {
2043 tests := []struct {
2044 name string
2045 steps []GitHubActionStep
2046 expected bool
2047 }{
2048 {
2049 name: "empty input",
2050 steps: nil,
2051 expected: false,
2052 },
2053 {
2054 name: "canonical setup-node step from GenerateNodeJsSetupStep",
2055 steps: []GitHubActionStep{GenerateNodeJsSetupStep()},
2056 expected: true,
2057 },
2058 {
2059 name: "install-only step without node setup",
2060 steps: []GitHubActionStep{
2061 {" - name: Install Some CLI", " run: npm install -g some-cli"},
2062 },
2063 expected: false,
2064 },
2065 {
2066 name: "setup-node preceded by unrelated step",
2067 steps: []GitHubActionStep{
2068 {" - name: Checkout", " uses: actions/checkout@v4"},
2069 GenerateNodeJsSetupStep(),
2070 },
2071 expected: true,
2072 },
2073 {
2074 name: "differently indented setup-node (extractStepName whitespace tolerance)",
2075 steps: []GitHubActionStep{
2076 {" - name: Setup Node.js", " uses: actions/setup-node@v4"},
2077 },
2078 expected: true,
2079 },
2080 }
2081
2082 for _, tt := range tests {
2083 t.Run(tt.name, func(t *testing.T) {
2084 got := installStepsContainNodeSetup(tt.steps)
2085 if got != tt.expected {
2086 t.Errorf("installStepsContainNodeSetup() = %v, want %v", got, tt.expected)
2087 }
2088 })
2089 }
2090}
2091
2092func TestBuildDetectionEngineExecutionStepPropagatesHarnessScriptOverride(t *testing.T) {
2093 compiler := NewCompiler()

Callers

nothing calls this directly

Calls 4

GenerateNodeJsSetupStepFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected