Skip to content

Commit

Permalink
Simplify API conformance tests (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Jul 19, 2017
1 parent 9e9e948 commit f53da86
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 52 deletions.
10 changes: 2 additions & 8 deletions plugin/storage/cassandra/dependencystore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@ func withDepStore(fn func(s *depStorageTest)) {
fn(s)
}

func TestNewDependencyStore(t *testing.T) {
withDepStore(func(s *depStorageTest) {
var reader dependencystore.Reader = s.storage // check API conformance
var writer dependencystore.Writer = s.storage // check API conformance
assert.NotNil(t, reader)
assert.NotNil(t, writer)
})
}
var _ dependencystore.Reader = &DependencyStore{} // check API conformance
var _ dependencystore.Writer = &DependencyStore{} // check API conformance

func TestDependencyStoreWrite(t *testing.T) {
withDepStore(func(s *depStorageTest) {
Expand Down
7 changes: 1 addition & 6 deletions plugin/storage/cassandra/samplingstore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ func withSamplingStore(fn func(r *samplingStoreTest)) {
fn(r)
}

func TestNewSamplingStore(t *testing.T) {
withSamplingStore(func(s *samplingStoreTest) {
var store samplingstore.Store = s.store // check API conformance
assert.NotNil(t, store)
})
}
var _ samplingstore.Store = &SamplingStore{} // check API conformance

func TestInsertThroughput(t *testing.T) {
withSamplingStore(func(s *samplingStoreTest) {
Expand Down
7 changes: 1 addition & 6 deletions plugin/storage/cassandra/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ func withSpanReader(fn func(r *spanReaderTest)) {
fn(r)
}

func TestNewSpanReader(t *testing.T) {
withSpanReader(func(r *spanReaderTest) {
var reader spanstore.Reader = r.reader // check API conformance
assert.NotNil(t, reader)
})
}
var _ spanstore.Reader = &SpanReader{} // check API conformance

func TestSpanReaderGetServices(t *testing.T) {
withSpanReader(func(r *spanReaderTest) {
Expand Down
7 changes: 1 addition & 6 deletions plugin/storage/cassandra/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,7 @@ func withSpanWriter(writeCacheTTL time.Duration, fn func(w *spanWriterTest)) {
fn(w)
}

func TestNewSpanWriter(t *testing.T) {
withSpanWriter(0, func(w *spanWriterTest) {
var writer spanstore.Writer = w.writer // check API conformance
assert.NotNil(t, writer)
})
}
var _ spanstore.Writer = &SpanWriter{} // check API conformance

func TestSpanWriter(t *testing.T) {
testCases := []struct {
Expand Down
10 changes: 2 additions & 8 deletions plugin/storage/es/dependencystore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ func withDepStorage(fn func(r *depStorageTest)) {
fn(r)
}

func TestAPIConformance(t *testing.T) {
withDepStorage(func(r *depStorageTest) {
var reader dependencystore.Reader = r.storage // check API conformance
var writer dependencystore.Writer = r.storage // check API conformance
assert.NotNil(t, reader)
assert.NotNil(t, writer)
})
}
var _ dependencystore.Reader = &DependencyStore{} // check API conformance
var _ dependencystore.Writer = &DependencyStore{} // check API conformance

func TestWriteDependencies(t *testing.T) {
testCases := []struct {
Expand Down
17 changes: 5 additions & 12 deletions plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"

"github.com/uber/jaeger-lib/metrics"
"github.com/uber/jaeger/model"
esJson "github.com/uber/jaeger/model/json"
"github.com/uber/jaeger/pkg/es/mocks"
Expand Down Expand Up @@ -100,19 +100,12 @@ func withSpanReader(fn func(r *spanReaderTest)) {
fn(r)
}

func TestAPIConformance(t *testing.T) {
client := &mocks.Client{}
logger, _ := testutils.NewLogger() // logBuffer unneeded
metricsFactory := metrics.NewLocalFactory(0)
var reader spanstore.Reader = NewSpanReader(client, logger, 0, metricsFactory) // check API conformance
assert.NotNil(t, reader)
}
var _ spanstore.Reader = &SpanReader{} // check API conformance

func TestNewSpanReader(t *testing.T) {
withSpanReader(func(r *spanReaderTest) {
var reader spanstore.Reader = r.reader // check API conformance
assert.NotNil(t, reader)
})
client := &mocks.Client{}
reader := NewSpanReader(client, zap.NewNop(), 0, metrics.NullFactory)
assert.NotNil(t, reader)
}

func TestSpanReader_GetTrace(t *testing.T) {
Expand Down
7 changes: 1 addition & 6 deletions plugin/storage/es/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ func withSpanWriter(fn func(w *spanWriterTest)) {
fn(w)
}

func TestNewSpanWriter(t *testing.T) {
withSpanWriter(func(w *spanWriterTest) {
var writer spanstore.Writer = w.writer
assert.NotNil(t, writer)
})
}
var _ spanstore.Writer = &SpanWriter{} // check API conformance

// This test behaves as a large test that checks WriteSpan's behavior as a whole.
// Extra tests for individual functions are below.
Expand Down

0 comments on commit f53da86

Please sign in to comment.