Browse Source

Fix rules_test.go

This is smelly, but for now we copy a helper method from the metric
tests into rules.
pull/251/merge
Bernerd Schaefer 12 years ago
parent
commit
aa96c7d141
  1. 40
      rules/rules_test.go

40
rules/rules_test.go

@ -49,8 +49,46 @@ func vectorComparisonString(expected []string, actual []string) string {
separator)
}
type testTieredStorageCloser struct {
storage *metric.TieredStorage
directory test.Closer
}
func (t testTieredStorageCloser) Close() {
t.storage.Close()
t.directory.Close()
}
// This is copied from storage/metric/helpers_test.go, which is unfortunate but
// presently required to make things work.
func NewTestTieredStorage(t test.Tester) (storage *metric.TieredStorage, closer test.Closer) {
var directory test.TemporaryDirectory
directory = test.NewTemporaryDirectory("test_tiered_storage", t)
storage, err := metric.NewTieredStorage(2500, 1000, 5*time.Second, 15*time.Second, 0*time.Second, directory.Path())
if err != nil {
if storage != nil {
storage.Close()
}
directory.Close()
t.Fatalf("Error creating storage: %s", err)
}
if storage == nil {
directory.Close()
t.Fatalf("storage == nil")
}
go storage.Serve()
closer = &testTieredStorageCloser{
storage: storage,
directory: directory,
}
return
}
func newTestStorage(t test.Tester) (storage *metric.TieredStorage, closer test.Closer) {
storage, closer = metric.NewTestTieredStorage(t)
storage, closer = NewTestTieredStorage(t)
if storage == nil {
t.Fatal("storage == nil")
}

Loading…
Cancel
Save