From 4e82fac442c42eeedd0f3e41e1a3fef4d6657738 Mon Sep 17 00:00:00 2001 From: Ed Zynda Date: Fri, 17 Apr 2026 12:13:28 +0300 Subject: [PATCH] fix(fileutil): decouple TestDetectMediaType from system MIME db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestDetectMediaType/.go fails on CI images (Ubuntu mime-support) where /etc/mime.types registers '.go → text/x-go', because mime.TypeByExtension reads those files at init. The test intended to exercise the 'unknown extension falls through to text/plain' branch but used a real extension, making the assertion environment-dependent. Replace '.go' with '.kitsyntheticext', an invented extension that no system MIME database registers. The fallback path is now exercised deterministically on any host. --- internal/ui/fileutil/processor_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/ui/fileutil/processor_test.go b/internal/ui/fileutil/processor_test.go index 5539483f..cefb2c01 100644 --- a/internal/ui/fileutil/processor_test.go +++ b/internal/ui/fileutil/processor_test.go @@ -145,7 +145,13 @@ func TestDetectMediaType(t *testing.T) { content []byte expected string }{ - {".go", nil, "text/plain"}, // .go falls back to content sniffing → text/plain + // An intentionally-synthetic extension that is not registered + // in any system MIME database. Exercises the "unknown ext + + // no content" branch, which must return the text/plain default. + // Do not use real extensions (e.g. .go) here: CI images often + // ship /etc/mime.types with entries like ".go → text/x-go", + // which would make the assertion environment-dependent. + {".kitsyntheticext", nil, "text/plain"}, {".png", []byte{0x89, 0x50, 0x4E, 0x47}, "image/png"}, {".jpg", []byte{0xFF, 0xD8, 0xFF}, "image/jpeg"}, {".pdf", []byte{0x25, 0x50, 0x44, 0x46}, "application/pdf"},