Move test package to pkg/testutil

This commit is contained in:
Fabian Reinartz 2015-05-28 20:58:38 +02:00
parent c44ac7bc26
commit 3c8fbf1e15
7 changed files with 16 additions and 16 deletions

View File

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package test
package testutil
import (
"io/ioutil"

View File

@ -11,7 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package test
package testutil
// ErrorEqual compares Go errors for equality.
func ErrorEqual(left, right error) bool {

View File

@ -29,7 +29,7 @@ import (
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility"
testutil "github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
var (

View File

@ -5,11 +5,11 @@ import (
"path/filepath"
"testing"
"github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
func TestLocking(t *testing.T) {
dir := test.NewTemporaryDirectory("test_flock", t)
dir := testutil.NewTemporaryDirectory("test_flock", t)
defer dir.Close()
fileName := filepath.Join(dir.Path(), "LOCK")

View File

@ -20,10 +20,10 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/pkg/testutil"
"github.com/prometheus/prometheus/storage/local/codable"
"github.com/prometheus/prometheus/storage/local/index"
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility/test"
)
var (
@ -34,16 +34,16 @@ var (
m5 = clientmodel.Metric{"label": "value5"}
)
func newTestPersistence(t *testing.T, encoding chunkEncoding) (*persistence, test.Closer) {
func newTestPersistence(t *testing.T, encoding chunkEncoding) (*persistence, testutil.Closer) {
*defaultChunkEncoding = int(encoding)
dir := test.NewTemporaryDirectory("test_persistence", t)
dir := testutil.NewTemporaryDirectory("test_persistence", t)
p, err := newPersistence(dir.Path(), false, false, func() bool { return false })
if err != nil {
dir.Close()
t.Fatal(err)
}
go p.run()
return p, test.NewCallbackCloser(func() {
return p, testutil.NewCallbackCloser(func() {
p.close()
dir.Close()
})

View File

@ -24,8 +24,8 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/pkg/testutil"
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/utility/test"
)
func TestFingerprintsForLabelMatchers(t *testing.T) {
@ -217,7 +217,7 @@ func TestLoop(t *testing.T) {
Value: clientmodel.SampleValue(float64(i) * 0.2),
}
}
directory := test.NewTemporaryDirectory("test_storage", t)
directory := testutil.NewTemporaryDirectory("test_storage", t)
defer directory.Close()
o := &MemorySeriesStorageOptions{
MemoryChunks: 50,
@ -902,7 +902,7 @@ func benchmarkFuzz(b *testing.B, encoding chunkEncoding) {
*defaultChunkEncoding = int(encoding)
const samplesPerRun = 100000
rand.Seed(42)
directory := test.NewTemporaryDirectory("test_storage", b)
directory := testutil.NewTemporaryDirectory("test_storage", b)
defer directory.Close()
o := &MemorySeriesStorageOptions{
MemoryChunks: 100,

View File

@ -21,12 +21,12 @@ package local
import (
"time"
"github.com/prometheus/prometheus/utility/test"
"github.com/prometheus/prometheus/pkg/testutil"
)
type testStorageCloser struct {
storage Storage
directory test.Closer
directory testutil.Closer
}
func (t *testStorageCloser) Close() {
@ -37,9 +37,9 @@ func (t *testStorageCloser) Close() {
// NewTestStorage creates a storage instance backed by files in a temporary
// directory. The returned storage is already in serving state. Upon closing the
// returned test.Closer, the temporary directory is cleaned up.
func NewTestStorage(t test.T, encoding chunkEncoding) (*memorySeriesStorage, test.Closer) {
func NewTestStorage(t testutil.T, encoding chunkEncoding) (*memorySeriesStorage, testutil.Closer) {
*defaultChunkEncoding = int(encoding)
directory := test.NewTemporaryDirectory("test_storage", t)
directory := testutil.NewTemporaryDirectory("test_storage", t)
o := &MemorySeriesStorageOptions{
MemoryChunks: 1000000,
MaxChunksToPersist: 1000000,