11import { getServiceClientEndpoint } from './service-endpoints' ;
22import { GeneratedServiceClientCtor } from './types' ;
33import SERVICE_ENDPOINTS_MAP from './service-endpoints-map.json' ;
4+ import { getServiceList } from '../scripts/check-endpoints' ;
45
56// eslint-disable-next-line @typescript-eslint/no-explicit-any
67type MockServiceClientCtor = GeneratedServiceClientCtor < any > ;
78
89describe ( 'service endpoints' , ( ) => {
9- it ( 'each service in generated service_clients module should have endpoint declared in service- endpoints-map ' , async ( ) => {
10+ it ( 'no empty endpoints' , async ( ) => {
1011 const missedEndpointsList : string [ ] = [ ] ;
1112
1213 Object . keys ( SERVICE_ENDPOINTS_MAP ) . forEach ( ( service ) => {
@@ -15,10 +16,36 @@ describe('service endpoints', () => {
1516 } ) ;
1617
1718 if ( missedEndpointsList . length !== 0 ) {
18- throw `\nMissed endpoints:\n${ missedEndpointsList . join ( '\n' ) } \n` ;
19+ throw `\nMissed endpoints in service-endpoints-map.json:\n${ missedEndpointsList . join (
20+ '\n' ,
21+ ) } \n`;
1922 }
2023 } ) ;
2124
25+ it ( 'each service should have endpoint' , async ( ) => {
26+ const serviceList = await getServiceList ( ) ;
27+ const missedEndpointsList : string [ ] = [ ] ;
28+
29+ serviceList . forEach ( ( s ) => {
30+ // full name without leading dot
31+ const serviceName = s . fullName . slice ( 1 ) ;
32+ let endpoint = '' ;
33+
34+ try {
35+ endpoint = getServiceClientEndpoint ( {
36+ serviceName,
37+ } as unknown as MockServiceClientCtor ) ;
38+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-empty
39+ } catch ( _err ) { }
40+
41+ if ( ! endpoint ) missedEndpointsList . push ( serviceName ) ;
42+ } ) ;
43+
44+ if ( missedEndpointsList . length !== 0 ) {
45+ throw `\nMissed endpoints:\n${ missedEndpointsList . join ( '\n' ) } \n` ;
46+ }
47+ } , 200_000 ) ;
48+
2249 it ( 'should throw exception if endpoint was not found' , ( ) => {
2350 const serviceName = 'myCustomService' ;
2451
0 commit comments