Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Oct 28, 2024
1 parent d9edbe3 commit fea6538
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spanner/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"go.opentelemetry.io/otel/metric/noop"
"sync"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -882,6 +883,10 @@ func TestRsdNonblockingStates(t *testing.T) {
}
return
}
mt.currOp.incrementAttemptCount()
mt.currOp.currAttempt = &attemptTracer{
startTime: time.Now(),
}
// Receive next decoded item.
if r.next(&mt) {
rs = append(rs, r.get())
Expand Down Expand Up @@ -1146,6 +1151,10 @@ func TestRsdBlockingStates(t *testing.T) {
var rs []*sppb.PartialResultSet
rowsFetched := make(chan int)
go func() {
mt.currOp.incrementAttemptCount()
mt.currOp.currAttempt = &attemptTracer{
startTime: time.Now(),
}
for {
if !r.next(&mt) {
// Note that r.Next also exits on context cancel/timeout.
Expand Down Expand Up @@ -1769,8 +1778,12 @@ func TestIteratorStopEarly(t *testing.T) {
}

func TestIteratorWithError(t *testing.T) {
metricsTracerFactory, err := newBuiltinMetricsTracerFactory(context.Background(), "projects/my-project/instances/my-instance/databases/my-database", noop.NewMeterProvider())
if err != nil {
t.Fatalf("failed to create metrics tracer factory: %v", err)
}
injected := errors.New("Failed iterator")
iter := RowIterator{err: injected}
iter := RowIterator{meterTracerFactory: metricsTracerFactory, err: injected}
defer iter.Stop()
if _, err := iter.Next(); err != injected {
t.Fatalf("Expected error: %v, got %v", injected, err)
Expand Down

0 comments on commit fea6538

Please sign in to comment.