Skip to content

Commit

Permalink
Cover close methods
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Jan 19, 2018
1 parent 020e8fa commit b59f73b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugin/storage/cassandra/spanstore/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func NewSpanWriter(

// Close closes SpanWriter
func (s *SpanWriter) Close() error {
s.Close()
s.session.Close()
return nil
}

Expand Down
8 changes: 8 additions & 0 deletions plugin/storage/cassandra/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func withSpanWriter(writeCacheTTL time.Duration, fn func(w *spanWriterTest)) {

var _ spanstore.Writer = &SpanWriter{} // check API conformance

func TestClientClose(t *testing.T) {
withSpanWriter(0, func(w *spanWriterTest) {
w.session.On("Close").Return(nil)
w.writer.Close()
w.session.AssertNumberOfCalls(t, "Close", 1)
})
}

func TestSpanWriter(t *testing.T) {
testCases := []struct {
caption string
Expand Down
8 changes: 8 additions & 0 deletions plugin/storage/es/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func withSpanWriter(fn func(w *spanWriterTest)) {

var _ spanstore.Writer = &SpanWriter{} // check API conformance

func TestClientClose(t *testing.T) {
withSpanWriter(func(w *spanWriterTest) {
w.client.On("Close").Return(nil)
w.writer.Close()
w.client.AssertNumberOfCalls(t, "Close", 1)
})
}

// This test behaves as a large test that checks WriteSpan's behavior as a whole.
// Extra tests for individual functions are below.
func TestSpanWriter_WriteSpan(t *testing.T) {
Expand Down

0 comments on commit b59f73b

Please # to comment.