Skip to content

Commit cd6c904

Browse files
committed
tests: don't use t.Errorf on regular strings
Linter start complining, switch to `t.Error`
1 parent f55f0d0 commit cd6c904

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

cassandra_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestUseStatementError(t *testing.T) {
100100

101101
if err := session.Query("USE gocql_test").Exec(); err != nil {
102102
if err != ErrUseStmt {
103-
t.Fatalf("expected ErrUseStmt, got " + err.Error())
103+
t.Fatalf("expected ErrUseStmt, got %v", err)
104104
}
105105
} else {
106106
t.Fatal("expected err, got nil.")
@@ -561,7 +561,7 @@ func TestCAS(t *testing.T) {
561561

562562
if _, err := session.Query(`DELETE FROM cas_table WHERE title = ? and revid = ? IF last_modified = ?`,
563563
title, revid, tenSecondsLater).ScanCAS(); !strings.HasPrefix(err.Error(), "gocql: not enough columns to scan into") {
564-
t.Fatalf("delete: was expecting count mismatch error but got: %q", err.Error())
564+
t.Fatalf("delete: was expecting count mismatch error but got: %v", err)
565565
}
566566

567567
if applied, err := session.Query(`DELETE FROM cas_table WHERE title = ? and revid = ? IF last_modified = ?`,

compressor_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestSnappyCompressor(t *testing.T) {
137137
}
138138

139139
if bytes.Compare(decoded, frame.Frame) != 0 {
140-
t.Fatalf("failed to match the decoded value with the original value")
140+
t.Fatal("failed to match the decoded value with the original value")
141141
}
142142
t.Logf("Compression rate %f", float64(len(encoded))/float64(len(frame.Frame)))
143143
})
@@ -156,7 +156,7 @@ func TestSnappyCompressor(t *testing.T) {
156156
}
157157

158158
if len(decoded) == 0 {
159-
t.Fatalf("frame was decoded to empty slice")
159+
t.Fatal("frame was decoded to empty slice")
160160
}
161161
})
162162
}

debounce/refresh_debouncer_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func TestErrorBroadcaster_MultipleListeners(t *testing.T) {
214214
}()
215215
wg.Wait()
216216
if loadedVal := result.Load(); loadedVal != nil {
217-
t.Errorf(loadedVal.(error).Error())
217+
t.Error(loadedVal.(error).Error())
218218
}
219219
}
220220

@@ -249,6 +249,6 @@ func TestErrorBroadcaster_StopWithoutBroadcast(t *testing.T) {
249249
}()
250250
wg.Wait()
251251
if loadedVal := result.Load(); loadedVal != nil {
252-
t.Errorf(loadedVal.(error).Error())
252+
t.Error(loadedVal.(error).Error())
253253
}
254254
}

integration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestAuthentication(t *testing.T) {
5454
session, err := cluster.CreateSession()
5555

5656
if err != nil {
57-
t.Fatalf("Authentication error: %s", err)
57+
t.Fatalf("Authentication error: %v", err)
5858
}
5959

6060
session.Close()
@@ -241,10 +241,10 @@ func TestApplicationInformation(t *testing.T) {
241241
break
242242
}
243243
if iter.Close() != nil {
244-
t.Fatalf("failed to execute query: %s", iter.Close().Error())
244+
t.Fatalf("failed to execute query: %v", iter.Close())
245245
}
246246
if !found {
247-
t.Fatalf("failed to find the application info row")
247+
t.Fatal("failed to find the application info row")
248248
}
249249
})
250250
}

policies_integration_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package gocql
55

66
import (
77
"context"
8-
"fmt"
98
"testing"
109
"time"
1110
)
@@ -68,24 +67,24 @@ func TestTokenAwareHostPolicy(t *testing.T) {
6867
func testIfPolicyInitializedProperly(t *testing.T, cluster *ClusterConfig, policy *tokenAwareHostPolicy) {
6968
_, err := cluster.CreateSession()
7069
if err != nil {
71-
t.Fatalf(fmt.Errorf("faled to create session: %v", err).Error())
70+
t.Fatalf("faled to create session: %s", err.Error())
7271
}
7372
md := policy.getMetadataReadOnly()
7473
if md == nil {
75-
t.Fatalf("tokenAwareHostPolicy has no metadata")
74+
t.Fatal("tokenAwareHostPolicy has no metadata")
7675
}
7776
if len(md.tokenRing.tokens) == 0 {
78-
t.Fatalf("tokenAwareHostPolicy metadata has no tokens")
77+
t.Fatal("tokenAwareHostPolicy metadata has no tokens")
7978
}
8079
if len(md.tokenRing.hosts) == 0 {
81-
t.Fatalf("tokenAwareHostPolicy metadata has no hosts")
80+
t.Fatal("tokenAwareHostPolicy metadata has no hosts")
8281
}
8382
if md.tokenRing.partitioner == nil {
84-
t.Fatalf("tokenAwareHostPolicy metadata has no partitioner")
83+
t.Fatal("tokenAwareHostPolicy metadata has no partitioner")
8584
}
8685
if cluster.Keyspace != "" {
8786
if len(md.replicas[cluster.Keyspace]) == 0 {
88-
t.Fatalf("tokenAwareHostPolicy metadata has no replicas in target keyspace")
87+
t.Fatal("tokenAwareHostPolicy metadata has no replicas in target keyspace")
8988
}
9089
}
9190
}

0 commit comments

Comments
 (0)