(path string)
| 406 | } |
| 407 | |
| 408 | func readTestData(path string) ([]test, error) { |
| 409 | yamlFile, err := os.Open(path) |
| 410 | if err != nil { |
| 411 | return nil, err |
| 412 | } |
| 413 | defer yamlFile.Close() |
| 414 | byteValue, err := io.ReadAll(yamlFile) |
| 415 | if err != nil { |
| 416 | return nil, err |
| 417 | } |
| 418 | type yamlStruct struct { |
| 419 | Statement string |
| 420 | Result []string |
| 421 | Run bool |
| 422 | } |
| 423 | var yamlTests []yamlStruct |
| 424 | if err := yaml.Unmarshal(byteValue, &yamlTests); err != nil { |
| 425 | return nil, err |
| 426 | } |
| 427 | |
| 428 | var tests []test |
| 429 | for _, yamlTest := range yamlTests { |
| 430 | t := test{ |
| 431 | Statement: yamlTest.Statement, |
| 432 | Run: yamlTest.Run, |
| 433 | } |
| 434 | for _, r := range yamlTest.Result { |
| 435 | result := &v1pb.PlanCheckRun_Result{} |
| 436 | if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(r), result); err != nil { |
| 437 | return nil, err |
| 438 | } |
| 439 | t.Result = append(t.Result, result) |
| 440 | } |
| 441 | tests = append(tests, t) |
| 442 | } |
| 443 | return tests, nil |
| 444 | } |
| 445 | |
| 446 | func writeTestData(filepath string, tests []test) error { |
| 447 | type yamlStruct struct { |
no test coverage detected