@@ -451,6 +451,21 @@ func Test_getGeneratorConfig(t *testing.T) {
451451 atom * pdoknlv3.Atom
452452 ownerInfo * smoothoperatorv1.OwnerInfo
453453 }
454+
455+ maxAtom , err := GetAtom (testPath ("maximum" )+ "input/atom.yaml" , false )
456+
457+ if err != nil {
458+ t .Errorf ("GetAtom() error = %v" , err )
459+ }
460+ maxOwner , err := getOwnerInfo (testPath ("maximum" )+ "input/ownerinfo.yaml" , false )
461+ if err != nil {
462+ t .Errorf ("getOwnerInfo() error = %v" , err )
463+ }
464+ maxScenario := args {
465+ atom : maxAtom ,
466+ ownerInfo : maxOwner ,
467+ }
468+
454469 tests := []struct {
455470 name string
456471 args args
@@ -468,17 +483,15 @@ func Test_getGeneratorConfig(t *testing.T) {
468483 wantErr : true ,
469484 },
470485 {
471- name : "succesfull_scenario_02" ,
472- args : args {
473- atom : getAtom (testPath ("maximum" )+ "input/atom.yaml" , false ),
474- ownerInfo : getOwnerInfo (testPath ("maximum" )+ "input/ownerinfo.yaml" , false ),
475- },
486+ name : "maximum_scenario" ,
487+ args : maxScenario ,
476488 wantConfig : getTestGeneratorConfig (testPath ("maximum" ) + "expected-output/configmap.yaml" ),
477489 wantErr : false ,
478490 },
479491 }
480492 for _ , tt := range tests {
481493 t .Run (tt .name , func (t * testing.T ) {
494+
482495 gotConfig , err := getGeneratorConfig (tt .args .atom , tt .args .ownerInfo )
483496 if (err != nil ) != tt .wantErr {
484497 t .Errorf ("getGeneratorConfig() error = %v, wantErr %v" , err , tt .wantErr )
@@ -496,30 +509,43 @@ func readTestFile(fileName string) (string, error) {
496509 return string (dat ), err
497510}
498511
499- func getAtom (fileName string , ginkgo bool ) * pdoknlv3.Atom {
512+ func GetAtom (fileName string , ginkgo bool ) ( * pdoknlv3.Atom , error ) {
500513 atom := & pdoknlv3.Atom {}
501514 data , err := os .ReadFile (fileName )
502515 if ginkgo {
503516 Expect (err ).NotTo (HaveOccurred ())
504517 }
518+ if err != nil {
519+ return nil , err
520+ }
521+
505522 err = yaml .UnmarshalStrict (data , atom )
506523 if ginkgo {
507524 Expect (err ).NotTo (HaveOccurred ())
508525 }
509- return atom
526+ if err != nil {
527+ return nil , err
528+ }
529+ return atom , nil
510530}
511531
512- func getOwnerInfo (fileName string , ginkgo bool ) * smoothoperatorv1.OwnerInfo {
532+ func getOwnerInfo (fileName string , ginkgo bool ) ( * smoothoperatorv1.OwnerInfo , error ) {
513533 owner := & smoothoperatorv1.OwnerInfo {}
514534 data , err := os .ReadFile (fileName )
515535 if ginkgo {
516536 Expect (err ).NotTo (HaveOccurred ())
517537 }
538+ if err != nil {
539+ return nil , err
540+ }
518541 err = yaml .UnmarshalStrict (data , owner )
519542 if ginkgo {
520543 Expect (err ).NotTo (HaveOccurred ())
521544 }
522- return owner
545+ if err != nil {
546+ return nil , err
547+ }
548+ return owner , nil
523549}
524550
525551func getTestGeneratorConfig (fileName string ) string {
0 commit comments