@@ -928,6 +928,74 @@ var _ = Describe("Integration Collect definitions + items", func() {
928
928
929
929
})
930
930
931
+ // TODO: spec title should be rephrased: should we have one spec for regression tests?
932
+ var _ = Describe ("Issue 943" , func () {
933
+ var (
934
+ mockCtrl * gomock.Controller
935
+ )
936
+
937
+ BeforeEach (func () {
938
+ mockCtrl = gomock .NewController (GinkgoT ())
939
+ })
940
+
941
+ AfterEach (func () {
942
+ mockCtrl .Finish ()
943
+ })
944
+
945
+ type testCase struct {
946
+ serviceContent map [string ]interface {}
947
+ expectedItems []* pipeline.BindingItem
948
+ secrets map [string ]* unstructured.Unstructured
949
+ configMaps map [string ]* unstructured.Unstructured
950
+ }
951
+
952
+ It ("retrieve binding data" ,
953
+ func () {
954
+ tc := testCase {
955
+ serviceContent : map [string ]interface {}{
956
+ "metadata" : map [string ]interface {}{
957
+ "annotations" : map [string ]interface {}{
958
+ "service.binding/java-maven_port" : "path={.status.ports},elementType=sliceOfMaps,sourceKey=name,sourceValue=asdf" ,
959
+ },
960
+ },
961
+ "status" : map [string ]interface {}{
962
+ "ports" : []interface {}{
963
+ map [string ]interface {}{"name" : "foo" , "value" : "bar" },
964
+ },
965
+ },
966
+ },
967
+ }
968
+
969
+ ctx := mocks .NewMockContext (mockCtrl )
970
+ service := mocks .NewMockService (mockCtrl )
971
+ serviceResource := & unstructured.Unstructured {Object : tc .serviceContent }
972
+
973
+ ctx .EXPECT ().Services ().Return ([]pipeline.Service {service }, nil ).MinTimes (1 )
974
+
975
+ var bindingDefs []binding.Definition
976
+ service .EXPECT ().AddBindingDef (gomock .Any ()).DoAndReturn (func (bd binding.Definition ) { bindingDefs = append (bindingDefs , bd ) }).Times (len (serviceResource .GetAnnotations ()))
977
+ service .EXPECT ().BindingDefs ().DoAndReturn (func () []binding.Definition { return bindingDefs })
978
+ service .EXPECT ().Resource ().Return (serviceResource ).Times (2 )
979
+
980
+ crd := mocks .NewMockCRD (mockCtrl )
981
+ crd .EXPECT ().Descriptor ().Return (nil , nil )
982
+ crd .EXPECT ().Resource ().Return (& unstructured.Unstructured {})
983
+ service .EXPECT ().CustomResourceDefinition ().Return (crd , nil )
984
+
985
+ // TODO: msg must be rephrased.
986
+ ctx .EXPECT ().SetCondition (
987
+ v1alpha1 .Conditions ().NotCollectionReady ().
988
+ Reason ("ValueNotFound" ).
989
+ Msg ("Value for key java-maven_port_foo not found" ).
990
+ Build ())
991
+
992
+ collect .BindingDefinitions (ctx )
993
+ collect .BindingItems (ctx )
994
+ },
995
+ )
996
+
997
+ })
998
+
931
999
type bindingDefMatcher struct {
932
1000
path []string
933
1001
}
0 commit comments