36 lines
800 B
Go
36 lines
800 B
Go
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestMailFileString(t *testing.T) {
|
|
clock := mockClock{}
|
|
timestamp := clock.Now()
|
|
progressive := 4
|
|
pid := 1312
|
|
hostname := "myplace"
|
|
name := "main_account" // known md5sum: f2cf513ad46d4d9b9684103e468803a0
|
|
uid := 33243
|
|
mf := &MailFile{timestamp: timestamp, progressive: progressive, pid: pid, hostname: hostname}
|
|
mf.SetFlags([]Flag{Seen, Answered})
|
|
mf.SetMd5FromName(name)
|
|
mf.SetUid(uid)
|
|
|
|
expect := fmt.Sprintf(
|
|
"%d_%d.%d.%s,U=%d,FMD5=f2cf513ad46d4d9b9684103e468803a0:2,RS",
|
|
timestamp.Unix(),
|
|
progressive,
|
|
pid,
|
|
hostname,
|
|
uid)
|
|
result := fmt.Sprint(mf)
|
|
|
|
if expect != result {
|
|
t.Errorf("Mismatch\n\tExpect: %s\n\tResult: %s\n", expect, result)
|
|
t.Logf("diff: %s", cmp.Diff(expect, result))
|
|
}
|
|
}
|