@@ -96,6 +96,71 @@ func TestDescribeODataClient_Mock(t *testing.T) {
9696 assertContainsStr (t , out , "2.0" )
9797}
9898
99+ func TestDescribeODataClient_NotFound (t * testing.T ) {
100+ mb := & mock.MockBackend {
101+ IsConnectedFunc : func () bool { return true },
102+ ListConsumedODataServicesFunc : func () ([]* model.ConsumedODataService , error ) {
103+ return nil , nil
104+ },
105+ }
106+ ctx , _ := newMockCtx (t , withBackend (mb ))
107+ assertError (t , describeODataClient (ctx , ast.QualifiedName {Module : "MyModule" , Name : "NoSuch" }))
108+ }
109+
110+ func TestShowODataClients_FilterByModule (t * testing.T ) {
111+ mod1 := mkModule ("Alpha" )
112+ mod2 := mkModule ("Beta" )
113+ svc1 := & model.ConsumedODataService {
114+ BaseElement : model.BaseElement {ID : nextID ("cos" )},
115+ ContainerID : mod1 .ID ,
116+ Name : "AlphaSvc" ,
117+ }
118+ svc2 := & model.ConsumedODataService {
119+ BaseElement : model.BaseElement {ID : nextID ("cos" )},
120+ ContainerID : mod2 .ID ,
121+ Name : "BetaSvc" ,
122+ }
123+ h := mkHierarchy (mod1 , mod2 )
124+ withContainer (h , svc1 .ContainerID , mod1 .ID )
125+ withContainer (h , svc2 .ContainerID , mod2 .ID )
126+
127+ mb := & mock.MockBackend {
128+ IsConnectedFunc : func () bool { return true },
129+ ListConsumedODataServicesFunc : func () ([]* model.ConsumedODataService , error ) {
130+ return []* model.ConsumedODataService {svc1 , svc2 }, nil
131+ },
132+ }
133+
134+ ctx , buf := newMockCtx (t , withBackend (mb ), withHierarchy (h ))
135+ assertNoError (t , listODataClients (ctx , "Alpha" ))
136+
137+ out := buf .String ()
138+ assertContainsStr (t , out , "Alpha.AlphaSvc" )
139+ assertNotContainsStr (t , out , "Beta.BetaSvc" )
140+ }
141+
142+ func TestShowODataServices_FilterByModule (t * testing.T ) {
143+ mod := mkModule ("Sales" )
144+ svc := & model.PublishedODataService {
145+ BaseElement : model.BaseElement {ID : nextID ("pos" )},
146+ ContainerID : mod .ID ,
147+ Name : "SalesSvc" ,
148+ }
149+ h := mkHierarchy (mod )
150+ withContainer (h , svc .ContainerID , mod .ID )
151+
152+ mb := & mock.MockBackend {
153+ IsConnectedFunc : func () bool { return true },
154+ ListPublishedODataServicesFunc : func () ([]* model.PublishedODataService , error ) {
155+ return []* model.PublishedODataService {svc }, nil
156+ },
157+ }
158+
159+ ctx , buf := newMockCtx (t , withBackend (mb ), withHierarchy (h ))
160+ assertNoError (t , listODataServices (ctx , "Sales" ))
161+ assertContainsStr (t , buf .String (), "Sales.SalesSvc" )
162+ }
163+
99164func TestDescribeODataService_Mock (t * testing.T ) {
100165 mod := mkModule ("MyModule" )
101166 svc := & model.PublishedODataService {
@@ -124,3 +189,14 @@ func TestDescribeODataService_Mock(t *testing.T) {
124189 assertContainsStr (t , out , "create odata service" )
125190 assertContainsStr (t , out , "MyModule.CatalogService" )
126191}
192+
193+ func TestDescribeODataService_NotFound (t * testing.T ) {
194+ mb := & mock.MockBackend {
195+ IsConnectedFunc : func () bool { return true },
196+ ListPublishedODataServicesFunc : func () ([]* model.PublishedODataService , error ) {
197+ return nil , nil
198+ },
199+ }
200+ ctx , _ := newMockCtx (t , withBackend (mb ))
201+ assertError (t , describeODataService (ctx , ast.QualifiedName {Module : "X" , Name : "NoSuch" }))
202+ }
0 commit comments