Skip to content

Commit fe3256d

Browse files
committed
Adding checks for errors to resolve linting errors
1 parent f48589f commit fe3256d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

sqlx_context_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ func TestUsageContext(t *testing.T) {
793793
t.Error("Expected an error")
794794
}
795795
err = stmt1.GetContext(ctx, &jason, "DoesNotExist User 2")
796+
if err != nil {
797+
t.Fatal(err)
798+
}
796799

797800
stmt2, err := db.PreparexContext(ctx, db.Rebind("SELECT * FROM person WHERE first_name=?"))
798801
if err != nil {
@@ -813,6 +816,10 @@ func TestUsageContext(t *testing.T) {
813816

814817
places := []*Place{}
815818
err = db.SelectContext(ctx, &places, "SELECT telcode FROM place ORDER BY telcode ASC")
819+
if err != nil {
820+
t.Fatal(err)
821+
}
822+
816823
usa, singsing, honkers := places[0], places[1], places[2]
817824

818825
if usa.TelCode != 1 || honkers.TelCode != 852 || singsing.TelCode != 65 {
@@ -830,6 +837,10 @@ func TestUsageContext(t *testing.T) {
830837
// this test also verifies that you can use either a []Struct{} or a []*Struct{}
831838
places2 := []Place{}
832839
err = db.SelectContext(ctx, &places2, "SELECT * FROM place ORDER BY telcode ASC")
840+
if err != nil {
841+
t.Fatal(err)
842+
}
843+
833844
usa, singsing, honkers = &places2[0], &places2[1], &places2[2]
834845

835846
// this should return a type error that &p is not a pointer to a struct slice

sqlx_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ func TestNamedQuery(t *testing.T) {
791791
email,
792792
place.id AS "place.id",
793793
place.name AS "place.name"
794-
FROM placeperson
794+
FROM placeperson
795795
INNER JOIN place ON place.id = placeperson.place_id
796796
WHERE
797797
place.id=:place.id`, pp)
@@ -967,6 +967,9 @@ func TestUsage(t *testing.T) {
967967
t.Error("Expected an error")
968968
}
969969
err = stmt1.Get(&jason, "DoesNotExist User 2")
970+
if err != nil {
971+
t.Fatal(err)
972+
}
970973

971974
stmt2, err := db.Preparex(db.Rebind("SELECT * FROM person WHERE first_name=?"))
972975
if err != nil {
@@ -987,6 +990,10 @@ func TestUsage(t *testing.T) {
987990

988991
places := []*Place{}
989992
err = db.Select(&places, "SELECT telcode FROM place ORDER BY telcode ASC")
993+
if err != nil {
994+
t.Fatal(err)
995+
}
996+
990997
usa, singsing, honkers := places[0], places[1], places[2]
991998

992999
if usa.TelCode != 1 || honkers.TelCode != 852 || singsing.TelCode != 65 {
@@ -1004,6 +1011,10 @@ func TestUsage(t *testing.T) {
10041011
// this test also verifies that you can use either a []Struct{} or a []*Struct{}
10051012
places2 := []Place{}
10061013
err = db.Select(&places2, "SELECT * FROM place ORDER BY telcode ASC")
1014+
if err != nil {
1015+
t.Fatal(err)
1016+
}
1017+
10071018
usa, singsing, honkers = &places2[0], &places2[1], &places2[2]
10081019

10091020
// this should return a type error that &p is not a pointer to a struct slice

0 commit comments

Comments
 (0)