@@ -49,6 +49,24 @@ tagNames:
4949 expect ( config ) . toBeDefined ( ) ;
5050 } ) ;
5151
52+ it ( 'should handle completely empty file' , async ( ) => {
53+ const filePath = path . join ( tmpDir , 'blank.yaml' ) ;
54+ await fs . writeFile ( filePath , '' , 'utf-8' ) ;
55+
56+ const config = await loadFilterConfig ( filePath ) ;
57+ expect ( config ) . toBeDefined ( ) ;
58+ expect ( config ) . toEqual ( { } ) ;
59+ } ) ;
60+
61+ it ( 'should handle file with only comments' , async ( ) => {
62+ const filePath = path . join ( tmpDir , 'comments.yaml' ) ;
63+ await fs . writeFile ( filePath , '# This is a comment\n# Another comment' , 'utf-8' ) ;
64+
65+ const config = await loadFilterConfig ( filePath ) ;
66+ expect ( config ) . toBeDefined ( ) ;
67+ expect ( config ) . toEqual ( { } ) ;
68+ } ) ;
69+
5270 it ( 'should throw for invalid type (non-array field)' , async ( ) => {
5371 const content = `
5472apiNames: "not-an-array"
@@ -123,6 +141,24 @@ backends:
123141 const config = await loadOverrideConfig ( path . join ( tmpDir , 'nonexistent.yaml' ) ) ;
124142 expect ( config ) . toBeUndefined ( ) ;
125143 } ) ;
144+
145+ it ( 'should handle completely empty file' , async ( ) => {
146+ const filePath = path . join ( tmpDir , 'blank.yaml' ) ;
147+ await fs . writeFile ( filePath , '' , 'utf-8' ) ;
148+
149+ const config = await loadOverrideConfig ( filePath ) ;
150+ expect ( config ) . toBeDefined ( ) ;
151+ expect ( config ) . toEqual ( { } ) ;
152+ } ) ;
153+
154+ it ( 'should handle file with only comments' , async ( ) => {
155+ const filePath = path . join ( tmpDir , 'comments.yaml' ) ;
156+ await fs . writeFile ( filePath , '# Override config\n# TODO: add overrides' , 'utf-8' ) ;
157+
158+ const config = await loadOverrideConfig ( filePath ) ;
159+ expect ( config ) . toBeDefined ( ) ;
160+ expect ( config ) . toEqual ( { } ) ;
161+ } ) ;
126162 } ) ;
127163
128164 describe ( 'loadOTelConfig' , ( ) => {
@@ -148,5 +184,23 @@ service:
148184 const config = await loadOTelConfig ( path . join ( tmpDir , 'nonexistent.yaml' ) ) ;
149185 expect ( config ) . toBeUndefined ( ) ;
150186 } ) ;
187+
188+ it ( 'should handle completely empty file' , async ( ) => {
189+ const filePath = path . join ( tmpDir , 'blank.yaml' ) ;
190+ await fs . writeFile ( filePath , '' , 'utf-8' ) ;
191+
192+ const config = await loadOTelConfig ( filePath ) ;
193+ expect ( config ) . toBeDefined ( ) ;
194+ expect ( config ) . toEqual ( { } ) ;
195+ } ) ;
196+
197+ it ( 'should handle file with only whitespace' , async ( ) => {
198+ const filePath = path . join ( tmpDir , 'whitespace.yaml' ) ;
199+ await fs . writeFile ( filePath , ' \n \n ' , 'utf-8' ) ;
200+
201+ const config = await loadOTelConfig ( filePath ) ;
202+ expect ( config ) . toBeDefined ( ) ;
203+ expect ( config ) . toEqual ( { } ) ;
204+ } ) ;
151205 } ) ;
152206} ) ;
0 commit comments