@@ -856,133 +856,3 @@ func TestCollectVolatileConfigItemsWithComponentNames(t *testing.T) {
856856 }
857857}
858858
859- func TestCriteriaGetWithComponentName (t * testing.T ) {
860- tests := []struct {
861- name string
862- criteria * Criteria
863- imageRef string
864- componentName string
865- expected []string
866- }{
867- {
868- name : "Component match - returns component-specific + global" ,
869- criteria : & Criteria {
870- digestItems : map [string ][]string {},
871- componentItems : map [string ][]string {
872- "my-component" : {"@minimal" , "test.some_policy" },
873- },
874- defaultItems : []string {"*" },
875- },
876- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
877- componentName : "my-component" ,
878- expected : []string {"@minimal" , "test.some_policy" , "*" },
879- },
880- {
881- name : "Component no match - returns only global" ,
882- criteria : & Criteria {
883- digestItems : map [string ][]string {},
884- componentItems : map [string ][]string {
885- "my-component" : {"@minimal" , "test.some_policy" },
886- },
887- defaultItems : []string {"*" },
888- },
889- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
890- componentName : "other-component" ,
891- expected : []string {"*" },
892- },
893- {
894- name : "Empty component name - returns only image + global" ,
895- criteria : & Criteria {
896- digestItems : map [string ][]string {
897- "quay.io/repo/img" : {"test.image_check" },
898- },
899- componentItems : map [string ][]string {
900- "my-component" : {"@minimal" },
901- },
902- defaultItems : []string {"*" },
903- },
904- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
905- componentName : "" ,
906- expected : []string {"test.image_check" , "*" },
907- },
908- {
909- name : "Image + Component both match - returns all merged" ,
910- criteria : & Criteria {
911- digestItems : map [string ][]string {
912- "quay.io/repo/img" : {"test.image_check" },
913- "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" : {"test.digest_check" },
914- },
915- componentItems : map [string ][]string {
916- "my-component" : {"test.component_check" },
917- },
918- defaultItems : []string {"*" },
919- },
920- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
921- componentName : "my-component" ,
922- expected : []string {"test.image_check" , "test.digest_check" , "test.component_check" , "*" },
923- },
924- {
925- name : "Invalid image ref - returns only global (error fallback)" ,
926- criteria : & Criteria {
927- digestItems : map [string ][]string {},
928- componentItems : map [string ][]string {
929- "my-component" : {"test.component_check" },
930- },
931- defaultItems : []string {"*" },
932- },
933- imageRef : "::::invalid:::::" ,
934- componentName : "my-component" ,
935- expected : []string {"*" },
936- },
937- {
938- name : "No matches at all - returns only global" ,
939- criteria : & Criteria {
940- digestItems : map [string ][]string {
941- "quay.io/other/img" : {"test.other_check" },
942- },
943- componentItems : map [string ][]string {
944- "other-component" : {"test.other_component" },
945- },
946- defaultItems : []string {"default1" , "default2" },
947- },
948- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
949- componentName : "my-component" ,
950- expected : []string {"default1" , "default2" },
951- },
952- {
953- name : "Multiple component items" ,
954- criteria : & Criteria {
955- digestItems : map [string ][]string {},
956- componentItems : map [string ][]string {
957- "my-component" : {"check1" , "check2" , "check3" },
958- },
959- defaultItems : []string {"*" },
960- },
961- imageRef : "quay.io/repo/img@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" ,
962- componentName : "my-component" ,
963- expected : []string {"check1" , "check2" , "check3" , "*" },
964- },
965- {
966- name : "Image without digest - returns only repo + component + global" ,
967- criteria : & Criteria {
968- digestItems : map [string ][]string {
969- "quay.io/repo/img" : {"test.image_check" },
970- },
971- componentItems : map [string ][]string {
972- "my-component" : {"test.component_check" },
973- },
974- defaultItems : []string {"*" },
975- },
976- imageRef : "quay.io/repo/img:latest" ,
977- componentName : "my-component" ,
978- expected : []string {"test.image_check" , "test.component_check" , "*" },
979- },
980- }
981-
982- for _ , tt := range tests {
983- t .Run (tt .name , func (t * testing.T ) {
984- result := tt .criteria .get (tt .imageRef , tt .componentName )
985- require .Equal (t , tt .expected , result )
986- })
987- }
988- }
0 commit comments