]> Cypherpunks repositories - gostls13.git/commitdiff
database/sql: fix unreachable code in ColumnTypes test
authorJulien Schmidt <google@julienschmidt.com>
Wed, 4 Oct 2017 15:26:14 +0000 (17:26 +0200)
committerDaniel Theophanes <kardianos@gmail.com>
Wed, 4 Oct 2017 16:30:44 +0000 (16:30 +0000)
Before this change the ct == 0 check could never be true. Moreover the
values were not properly indirected.

Change-Id: Ice47e36e3492babc4b47d2f9099e8772be231c96
Reviewed-on: https://go-review.googlesource.com/68130
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/database/sql/sql_test.go

index fe7c3278c7154fe7b513127ae5ddb7f193f5980d..046d95aff47bb9231756bc6b77c6fec1eaef20e6 100644 (file)
@@ -726,15 +726,15 @@ func TestRowsColumnTypes(t *testing.T) {
                if err != nil {
                        t.Fatalf("failed to scan values in %v", err)
                }
-               ct++
-               if ct == 0 {
-                       if values[0].(string) != "Bob" {
-                               t.Errorf("Expected Bob, got %v", values[0])
+               if ct == 1 {
+                       if age := *values[0].(*int32); age != 2 {
+                               t.Errorf("Expected 2, got %v", age)
                        }
-                       if values[1].(int) != 2 {
-                               t.Errorf("Expected 2, got %v", values[1])
+                       if name := *values[1].(*string); name != "Bob" {
+                               t.Errorf("Expected Bob, got %v", name)
                        }
                }
+               ct++
        }
        if ct != 3 {
                t.Errorf("expected 3 rows, got %d", ct)