@@ -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 {
@@ -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.