Esempio n. 1
0
func (tester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	defer test.TLog(t)()
	var cleanups []func()
	defer func() {
		for _, fn := range cleanups {
			fn()
		}
	}()

	initIndex := func() *index.Index {
		kv, cleanup := newSorted(t)
		cleanups = append(cleanups, cleanup)
		return index.MustNew(t, kv)
	}

	tfn(t, initIndex)
}
Esempio n. 2
0
func (tester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	var mu sync.Mutex // guards cleanups
	var cleanups []func()
	defer func() {
		mu.Lock() // never unlocked
		for _, fn := range cleanups {
			fn()
		}
	}()
	makeIndex := func() *index.Index {
		s, cleanup := newSorted(t)
		mu.Lock()
		cleanups = append(cleanups, cleanup)
		mu.Unlock()
		return index.MustNew(t, s)
	}
	tfn(t, makeIndex)
}
Esempio n. 3
0
func (mongoTester) test(t *testing.T, tfn func(*testing.T, func() *index.Index)) {
	defer test.TLog(t)()
	var mu sync.Mutex // guards cleanups
	var cleanups []func()
	defer func() {
		mu.Lock() // never unlocked
		for _, fn := range cleanups {
			fn()
		}
	}()
	initIndex := func() *index.Index {
		kv, cleanup := newSorted(t)
		mu.Lock()
		cleanups = append(cleanups, cleanup)
		mu.Unlock()
		return index.MustNew(t, kv)
	}
	tfn(t, initIndex)
}
Esempio n. 4
0
func indexTest(t *testing.T,
	sortedGenfn func(t *testing.T) (sorted.KeyValue, func()),
	tfn func(*testing.T, func() *index.Index)) {
	defer test.TLog(t)()
	var mu sync.Mutex // guards cleanups
	var cleanups []func()
	defer func() {
		mu.Lock() // never unlocked
		for _, fn := range cleanups {
			fn()
		}
	}()
	makeIndex := func() *index.Index {
		s, cleanup := sortedGenfn(t)
		mu.Lock()
		cleanups = append(cleanups, cleanup)
		mu.Unlock()
		return index.MustNew(t, s)
	}
	tfn(t, makeIndex)
}