func newTestMetric(t testing.TB) (m *metric, cleanup func()) {
	t.Helper()
	dir, err := ioutil.TempDir("", "metric-")
	assert.NoError(t, err)
	fch := newFileCache(fileCacheOptions{
		Handles: 100,
		Size:    1024,
		Cap:     10,
	})
	opts := metricOptions{
		fch:  fch,
		dir:  dir,
		name: "test.metric",
		max:  10,
	}
	m, err = newMetric(ctx, opts)
	assert.NoError(t, err)
	return m, func() {
		fch.Close()
		os.RemoveAll(dir)
	}
}
newTestMetric constructs a temporary metric.
package files
import (
	"bytes"
	"context"
	"encoding/binary"
	"io/ioutil"
	"os"
	"testing"
	"github.com/vivint/rothko/internal/assert"
	"github.com/zeebo/errs"
)