diff --git a/fetcher/fetcher.go b/fetcher/fetcher.go index 0b83c48918e031af6e190f6ac9096963ae26fef6..c5435a26a04fecbfc9aa33b4680539259eb34de5 100644 --- a/fetcher/fetcher.go +++ b/fetcher/fetcher.go @@ -323,7 +323,7 @@ func parsePartID(partID string) []int { // formatPartPath converts a Walk path like []int{1, 2, 3} to "1.2.3". func formatPartPath(path []int) string { if len(path) == 0 { - return "1" + return "" } parts := make([]string, len(path)) for i, p := range path { diff --git a/fetcher/fetcher_test.go b/fetcher/fetcher_test.go index af4c3790f2bcd626a2a439dbf9dc924a60ee9f99..92eaa93742cf1cc29813b0ce9b9975b87fa781cf 100644 --- a/fetcher/fetcher_test.go +++ b/fetcher/fetcher_test.go @@ -75,6 +75,20 @@ func TestLookupCharsetEncodingAlwaysReturnsNonNil(t *testing.T) { } } +func TestFormatPartPathEmptyPath(t *testing.T) { + cases := map[string][]int{ + "nil": nil, + "empty": {}, + } + for name, path := range cases { + t.Run(name, func(t *testing.T) { + if got := formatPartPath(path); got != "" { + t.Fatalf("formatPartPath(%v) = %q, want empty string", path, got) + } + }) + } +} + // TestFetchEmails is an integration test that requires a live IMAP server and valid credentials. // NOTE: This test will be skipped if it cannot load a configuration file, // making it safe to run in a CI environment without credentials.