@@ -164,11 +164,33 @@ func TestLoadFromFile_MissingFieldsKeepDefaults(t *testing.T) {
164164 if cfg .Volume != defaults .Volume {
165165 t .Errorf ("Volume = %d, want default %d" , cfg .Volume , defaults .Volume )
166166 }
167+ if cfg .BufferSeconds != defaults .BufferSeconds {
168+ t .Errorf ("BufferSeconds = %d, want default %d" , cfg .BufferSeconds , defaults .BufferSeconds )
169+ }
170+ if cfg .InitialBufferSeconds != defaults .InitialBufferSeconds {
171+ t .Errorf ("InitialBufferSeconds = %d, want default %d" , cfg .InitialBufferSeconds , defaults .InitialBufferSeconds )
172+ }
167173 if len (cfg .Stations ) != 1 || cfg .Stations [0 ].Name != "Only" {
168174 t .Errorf ("Stations = %+v, want [{Only http://x}]" , cfg .Stations )
169175 }
170176}
171177
178+ func TestLoadFromFile_ExplicitZeroBufferDisablesTuning (t * testing.T ) {
179+ dir := t .TempDir ()
180+ path := filepath .Join (dir , "config.yaml" )
181+ body := []byte ("theme: tokyo-night\n volume: 60\n buffer_seconds: 0\n initial_buffer_seconds: 0\n stations: []\n " )
182+ if err := os .WriteFile (path , body , 0o644 ); err != nil {
183+ t .Fatalf ("seed file: %v" , err )
184+ }
185+ cfg , err := loadFromFile (path )
186+ if err != nil {
187+ t .Fatalf ("loadFromFile: %v" , err )
188+ }
189+ if cfg .BufferSeconds != 0 || cfg .InitialBufferSeconds != 0 {
190+ t .Fatalf ("buffer settings = %d/%d, want explicit zeroes" , cfg .BufferSeconds , cfg .InitialBufferSeconds )
191+ }
192+ }
193+
172194func TestLoadFromFile_InvalidYAMLReturnsError (t * testing.T ) {
173195 dir := t .TempDir ()
174196 path := filepath .Join (dir , "config.yaml" )
@@ -214,6 +236,12 @@ func TestDefaultsAreNonEmpty(t *testing.T) {
214236 if d .Volume < 0 || d .Volume > 100 {
215237 t .Errorf ("Defaults().Volume = %d, want 0..100" , d .Volume )
216238 }
239+ if d .BufferSeconds <= 0 {
240+ t .Errorf ("Defaults().BufferSeconds = %d, want positive" , d .BufferSeconds )
241+ }
242+ if d .InitialBufferSeconds < 0 {
243+ t .Errorf ("Defaults().InitialBufferSeconds = %d, want non-negative" , d .InitialBufferSeconds )
244+ }
217245 if len (d .Stations ) == 0 {
218246 t .Error ("Defaults().Stations is empty" )
219247 }
@@ -295,4 +323,3 @@ stations:
295323 t .Errorf ("station IsYouTube() = false, want true" )
296324 }
297325}
298-
0 commit comments