(t *testing.T)
| 233 | } |
| 234 | } |
| 235 | func TestHasScript(t *testing.T) { |
| 236 | testCases := []struct { |
| 237 | name string |
| 238 | packageJSON *PackageJSON |
| 239 | script string |
| 240 | want bool |
| 241 | }{ |
| 242 | { |
| 243 | name: "nil package.json", |
| 244 | packageJSON: nil, |
| 245 | want: false, |
| 246 | }, |
| 247 | { |
| 248 | name: "matching script", |
| 249 | packageJSON: &PackageJSON{ |
| 250 | Scripts: map[string]string{ |
| 251 | "gcp-build": "my-script", |
| 252 | }, |
| 253 | }, |
| 254 | script: "gcp-build", |
| 255 | want: true, |
| 256 | }, |
| 257 | { |
| 258 | name: "mismatching script", |
| 259 | packageJSON: &PackageJSON{ |
| 260 | Scripts: map[string]string{ |
| 261 | "gcp-build": "my-script", |
| 262 | }, |
| 263 | }, |
| 264 | script: "build", |
| 265 | want: false, |
| 266 | }, |
| 267 | { |
| 268 | name: "matching empty script", |
| 269 | packageJSON: &PackageJSON{ |
| 270 | Scripts: map[string]string{"gcp-build": ""}, |
| 271 | }, |
| 272 | script: "gcp-build", |
| 273 | want: true, |
| 274 | }, |
| 275 | } |
| 276 | |
| 277 | for _, tc := range testCases { |
| 278 | t.Run(tc.name, func(t *testing.T) { |
| 279 | got := HasScript(tc.packageJSON, tc.script) |
| 280 | if got != tc.want { |
| 281 | t.Errorf("HasGCPBuild(%v) = %t, want %t", tc.packageJSON, got, tc.want) |
| 282 | } |
| 283 | }) |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | func TestHasDevDependencies(t *testing.T) { |
| 288 | testCases := []struct { |
nothing calls this directly
no test coverage detected