File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { App , Chart , Service , Testing } from '../../src' ;
2+
3+ describe ( 'service' , ( ) => {
4+ test ( 'allows headless service without ports' , ( ) => {
5+ const app = new App ( ) ;
6+ const chart = new Chart ( app , 'test' ) ;
7+
8+ new Service ( chart , 'Service' , {
9+ clusterIP : 'None' ,
10+ selector : {
11+ app : 'foo' ,
12+ } ,
13+ } ) ;
14+
15+ const manifests = Testing . synth ( chart ) ;
16+ const service = manifests . find ( ( m ) => m . kind === 'Service' ) as any ;
17+
18+ expect ( service ) . toMatchObject ( {
19+ spec : {
20+ clusterIP : 'None' ,
21+ } ,
22+ } ) ;
23+ expect ( service . spec . ports ?? [ ] ) . toEqual ( [ ] ) ;
24+ } ) ;
25+
26+ test ( 'requires a port for non-headless services' , ( ) => {
27+ const app = new App ( ) ;
28+ const chart = new Chart ( app , 'test' ) ;
29+
30+ expect ( ( ) => {
31+ new Service ( chart , 'Service' , {
32+ selector : {
33+ app : 'foo' ,
34+ } ,
35+ } ) ;
36+
37+ Testing . synth ( chart ) ;
38+ } ) . toThrow ( / p o r t / i) ;
39+ } ) ;
40+ } ) ;
You can’t perform that action at this time.
0 commit comments