@@ -14,6 +14,7 @@ func TestServeStatic_CustomPages(t *testing.T) {
1414 // Test 404 - File Not Found
1515 t .Run ("404 Custom Page" , func (t * testing.T ) {
1616 req := httptest .NewRequest ("GET" , "/nonexistent.html" , nil )
17+ req .Header .Set ("Accept" , "text/html" )
1718 w := httptest .NewRecorder ()
1819
1920 ServeStatic (w , req , rootDir )
@@ -28,14 +29,15 @@ func TestServeStatic_CustomPages(t *testing.T) {
2829 t .Error ("Expected body to contain 'GoUp'" )
2930 }
3031 if ! strings .Contains (body , "Page Not Found" ) {
31- t .Error ("Expected body to contain 'Page Not Found'" )
32+ t .Errorf ("Expected body to contain 'Page Not Found', got: %s" , body )
3233 }
3334 })
3435
3536 // Test Welcome Page - Missing Index
3637 t .Run ("Welcome Page" , func (t * testing.T ) {
3738 // Ensure rootDir is empty/exists but has no index.html
3839 req := httptest .NewRequest ("GET" , "/" , nil )
40+ req .Header .Set ("Accept" , "text/html" )
3941 w := httptest .NewRecorder ()
4042
4143 ServeStatic (w , req , rootDir )
@@ -46,8 +48,8 @@ func TestServeStatic_CustomPages(t *testing.T) {
4648 }
4749
4850 body := w .Body .String ()
49- if ! strings .Contains (body , "Welcome to GoUp " ) {
50- t .Error ("Expected body to contain 'Welcome to GoUp'" )
51+ if ! strings .Contains (body , "Index of " ) {
52+ t .Errorf ("Expected body to contain 'Index of' (directory listing), got: %s" , body )
5153 }
5254 if ! strings .Contains (body , "<!DOCTYPE html>" ) {
5355 t .Error ("Expected HTML response (template execution), got fallback text" )
0 commit comments