Skip to content

Commit

Permalink
Force close rows for more deterministic test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-normand committed May 5, 2022
1 parent 55d49b5 commit 2f85370
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contrib/database/sql/conn.go
Expand Up @@ -221,7 +221,7 @@ func (tp *traceParams) tryStartTrace(ctx context.Context, qtype queryType, query
// optional interface method is not implemented. There is
// nothing to trace here.
// See: https://github.com/DataDog/dd-trace-go/issues/270
return
return nil
}
if _, exists := tracer.SpanFromContext(ctx); tp.cfg.childSpansOnly && !exists {
return nil
Expand Down
6 changes: 3 additions & 3 deletions contrib/internal/sqltest/sqltest.go
Expand Up @@ -122,15 +122,15 @@ func testQuery(cfg *Config) func(*testing.T) {
cfg.mockTracer.Reset()
assert := assert.New(t)
rows, err := cfg.DB.Query(query)
defer rows.Close()
rows.Close()
assert.Nil(err)

spans := cfg.mockTracer.FinishedSpans()
var querySpan mocktracer.Span
if cfg.DriverName == "sqlserver" {
//The mssql driver doesn't support non-prepared queries so there are 3 spans
//connect, prepare, and query
assert.Len(spans, 3)
//connect, prepare, query and close
assert.Len(spans, 4)
span := spans[1]
cfg.ExpectTags["sql.query_type"] = "Prepare"
assert.Equal(cfg.ExpectName, span.OperationName())
Expand Down

0 comments on commit 2f85370

Please sign in to comment.