Add test on MailFile parsing failure
This commit is contained in:
parent
b74764b71a
commit
4b283db0f1
1 changed files with 20 additions and 0 deletions
|
@ -2,6 +2,7 @@ package fs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -75,3 +76,22 @@ func TestNewMailFile(t *testing.T) {
|
||||||
t.Errorf("MailFile mismatch: %s", cmp.Diff(expect, mf, cmp.AllowUnexported(MailFile{})))
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue