(t *testing.T)
| 368 | } |
| 369 | |
| 370 | func TestValidateBalancedQuotes(t *testing.T) { |
| 371 | tests := []struct { |
| 372 | name string |
| 373 | expr string |
| 374 | wantErr bool |
| 375 | errorInMsg string |
| 376 | }{ |
| 377 | { |
| 378 | name: "no quotes", |
| 379 | expr: "github.workflow", |
| 380 | wantErr: false, |
| 381 | }, |
| 382 | { |
| 383 | name: "balanced single quotes", |
| 384 | expr: "github.workflow == 'test'", |
| 385 | wantErr: false, |
| 386 | }, |
| 387 | { |
| 388 | name: "balanced double quotes", |
| 389 | expr: "github.workflow == \"test\"", |
| 390 | wantErr: false, |
| 391 | }, |
| 392 | { |
| 393 | name: "balanced backticks", |
| 394 | expr: "github.workflow == `test`", |
| 395 | wantErr: false, |
| 396 | }, |
| 397 | { |
| 398 | name: "mixed balanced quotes", |
| 399 | expr: "github.workflow == 'test' || github.ref == \"value\"", |
| 400 | wantErr: false, |
| 401 | }, |
| 402 | { |
| 403 | name: "escaped quote inside string", |
| 404 | expr: "github.workflow == 'test\\'s'", |
| 405 | wantErr: false, |
| 406 | }, |
| 407 | { |
| 408 | name: "unclosed single quote", |
| 409 | expr: "github.workflow == 'test", |
| 410 | wantErr: true, |
| 411 | errorInMsg: "unclosed single quote", |
| 412 | }, |
| 413 | { |
| 414 | name: "unclosed double quote", |
| 415 | expr: "github.workflow == \"test", |
| 416 | wantErr: true, |
| 417 | errorInMsg: "unclosed double quote", |
| 418 | }, |
| 419 | { |
| 420 | name: "unclosed backtick", |
| 421 | expr: "github.workflow == `test", |
| 422 | wantErr: true, |
| 423 | errorInMsg: "unclosed backtick", |
| 424 | }, |
| 425 | } |
| 426 | |
| 427 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected