|
@@ -2,6 +2,7 @@ package fs
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "strconv"
|
|
|
"testing"
|
|
|
"time"
|
|
|
|
|
@@ -75,3 +76,22 @@ func TestNewMailFile(t *testing.T) {
|
|
|
t.Errorf("MailFile mismatch: %s", cmp.Diff(expect, mf, cmp.AllowUnexported(MailFile{})))
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestNewMailFileErrs(t *testing.T) {
|
|
|
+ var err error
|
|
|
+
|
|
|
+ // The name has the wrong shape
|
|
|
+ _, err = NewMailFile("pippo")
|
|
|
+ if err != ErrMalformedName {
|
|
|
+ t.Error("Function should have errored")
|
|
|
+ }
|
|
|
+
|
|
|
+ // The shape is correct, but one of the integer field is instead a string
|
|
|
+ _, err = NewMailFile("aaaa_123.456.myplace,U=1312,FMD5=f2cf513ad46d4d9b9684103e468803a0:2,")
|
|
|
+ switch err.(type) {
|
|
|
+ case *strconv.NumError:
|
|
|
+ // Happy path
|
|
|
+ default:
|
|
|
+ t.Error("Unexpected error")
|
|
|
+ }
|
|
|
+}
|