func TestFSMissing(t *testing.T) {
	ds, logbuf := setupDataStore(config.Storage{})
	defer teardownDataStore(ds)
	mbName := "fred"
	subjects := []string{"a", "b", "c"}
	sentIds := make([]string, len(subjects))
	for i, subj := range subjects {
		id, _ := deliverMessage(ds, mbName, subj, time.Now())
		sentIds[i] = id
	}
	msg, err := ds.GetMessage(mbName, sentIds[1])
	assert.Nil(t, err)
	fmsg := msg.(*Message)
	_ = os.Remove(fmsg.rawPath())
	msg, err = ds.GetMessage(mbName, sentIds[1])
	assert.Nil(t, err)
	_, err = msg.Source()
	assert.Error(t, err)
	if t.Failed() {
		time.Sleep(2 * time.Second)
		_, _ = io.Copy(os.Stderr, logbuf)
	}
}
Test missing files
package file
import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/mail"
	"os"
	"path/filepath"
	"strings"
	"testing"
	"time"
	"github.com/inbucket/inbucket/pkg/config"
	"github.com/inbucket/inbucket/pkg/message"
	"github.com/inbucket/inbucket/pkg/storage"
	"github.com/inbucket/inbucket/pkg/test"
	"github.com/stretchr/testify/assert"
)
func TestSuite(t *testing.T) {
	test.StoreSuite(t, func(conf config.Storage) (storage.Store, func(), error) {
		ds, _ := setupDataStore(conf)
		destroy := func() {
			teardownDataStore(ds)
		}
		return ds, destroy, nil
	})
}
func TestFSDirStructure(t *testing.T) {
	ds, logbuf := setupDataStore(config.Storage{})
	defer teardownDataStore(ds)
	root := ds.path
	mbName := "james"
	assert.True(t, isDir(root), "Expected %q to be a directory", root)
	expect := filepath.Join(root, "mail")
	assert.True(t, isDir(expect), "Expected %q to be a directory", expect)
	expect = filepath.Join(root, "mail", "474")
	assert.False(t, isDir(expect), "Expected %q to not exist", expect)
	id1, _ := deliverMessage(ds, mbName, "test", time.Now())
	assert.True(t, isDir(expect), "Expected %q to be a directory", expect)
	expect = filepath.Join(expect, "474ba6")
	assert.True(t, isDir(expect), "Expected %q to be a directory", expect)
	expect = filepath.Join(expect, "474ba67bdb289c6263b36dfd8a7bed6c85b04943")
	assert.True(t, isDir(expect), "Expected %q to be a directory", expect)
	mbPath := expect
	expect = filepath.Join(mbPath, "index.gob")
	assert.True(t, isFile(expect), "Expected %q to be a file", expect)
	expect = filepath.Join(mbPath, id1+".raw")
	assert.True(t, isFile(expect), "Expected %q to be a file", expect)
	id2, _ := deliverMessage(ds, mbName, "test 2", time.Now())
	expect = filepath.Join(mbPath, "index.gob")
	assert.True(t, isFile(expect), "Expected %q to be a file", expect)
	expect = filepath.Join(mbPath, id2+".raw")
	assert.True(t, isFile(expect), "Expected %q to be a file", expect)
	err := ds.RemoveMessage(mbName, id1)
	assert.Nil(t, err)
	expect = filepath.Join(mbPath, id1+".raw")
	assert.False(t, isPresent(expect), "Did not expect %q to exist", expect)
	expect = filepath.Join(mbPath, "index.gob")
	assert.True(t, isFile(expect), "Expected %q to be a file", expect)
	err = ds.RemoveMessage(mbName, id2)
	assert.Nil(t, err)
	expect = filepath.Join(mbPath, id2+".raw")
	assert.False(t, isPresent(expect), "Did not expect %q to exist", expect)
	expect = filepath.Join(mbPath, "index.gob")
	assert.False(t, isPresent(expect), "Did not expect %q to exist", expect)
	expect = mbPath
	assert.False(t, isPresent(expect), "Did not expect %q to exist", expect)
	if t.Failed() {
		time.Sleep(2 * time.Second)
		_, _ = io.Copy(os.Stderr, logbuf)
	}
}