Skip to content
Snippets Groups Projects
Commit ba5d9e33 authored by Pawel Rozlach's avatar Pawel Rozlach Committed by João Pereira
Browse files

test: rewrite in-memory tests to use testify.suite

parent c56fd96c
No related branches found
No related tags found
1 merge request!1837test: rewrite in-memory tests to use testify.suite
package inmemory
import (
"context"
"testing"
storagedriver "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/testsuites"
"gopkg.in/check.v1"
"github.com/stretchr/testify/suite"
)
// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { check.TestingT(t) }
func TestInMemoryDriverSuite(t *testing.T) {
ts := testsuites.NewDriverSuite(
context.Background(),
func() (storagedriver.StorageDriver, error) {
return New(), nil
},
nil,
)
suite.Run(t, ts)
}
func BenchmarkInMemoryDriverSuite(b *testing.B) {
ts := testsuites.NewDriverSuite(
context.Background(),
func() (storagedriver.StorageDriver, error) {
return New(), nil
},
nil,
)
ts.SetupSuiteWithB(b)
b.Cleanup(func() { ts.TearDownSuiteWithB(b) })
// NOTE(prozlach): This is a method of embedded function, we need to pass
// the reference to "outer" struct directly
benchmarks := ts.EnumerateBenchmarks()
func init() {
inmemoryDriverConstructor := func() (storagedriver.StorageDriver, error) {
return New(), nil
for _, benchmark := range benchmarks {
b.Run(benchmark.Name, benchmark.Func)
}
testsuites.RegisterSuite(inmemoryDriverConstructor, testsuites.NeverSkip)
}
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment