Skip to content

Commit

Permalink
NO-SNOW Fix tests failing on Jenkins (#1258)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pfus authored Dec 5, 2024
1 parent e8d7ff2 commit 09f4086
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 3 additions & 0 deletions connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ func TestIsPrivateLink(t *testing.T) {
}

func TestBuildPrivatelinkConn(t *testing.T) {
os.Unsetenv(cacheServerURLEnv)
os.Unsetenv(ocspRetryURLEnv)

if _, err := buildSnowflakeConn(context.Background(), Config{
Account: "testaccount",
User: "testuser",
Expand Down
7 changes: 4 additions & 3 deletions put_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"compress/gzip"
"context"
"database/sql"
"fmt"
"io"
"math/rand"
Expand Down Expand Up @@ -214,14 +215,14 @@ func TestPutLocalFile(t *testing.T) {
dbt.mustExec(execQuery)
dbt.mustQueryAssertCount("ls @%gotest_putget_t1", 2)

var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 string
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 sql.NullString
rows := dbt.mustQuery("copy into gotest_putget_t1")
defer func() {
assertNilF(t, rows.Close())
}()
for rows.Next() {
assertNilF(t, rows.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9))
if s1 != "LOADED" {
if !s1.Valid || s1.String != "LOADED" {
t.Fatal("not loaded")
}
}
Expand All @@ -244,7 +245,7 @@ func TestPutLocalFile(t *testing.T) {
}()
if rows3.Next() {
assertNilF(t, rows3.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9))
if s1 != "LOADED" {
if !s1.Valid || s1.String != "LOADED" {
t.Fatal("not loaded")
}
}
Expand Down
17 changes: 9 additions & 8 deletions put_get_with_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"compress/gzip"
"context"
"database/sql"
"encoding/json"
"fmt"
"io"
Expand Down Expand Up @@ -71,9 +72,9 @@ func TestLoadS3(t *testing.T) {
field_optionally_enclosed_by='\"')`,
data.awsAccessKeyID, data.awsSecretAccessKey))
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 string
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9 sql.NullString
cnt := 0
for rows.Next() {
assertNilF(t, rows.Scan(&s0, &s1, &s2, &s3, &s4, &s5, &s6, &s7, &s8, &s9))
Expand All @@ -82,7 +83,7 @@ func TestLoadS3(t *testing.T) {
if cnt != 1 {
t.Fatal("copy into tweets did not set row count to 1")
}
if s0 != "s3://sfc-eng-data/twitter/O1k/tweets/1.csv.gz" {
if !s0.Valid || s0.String != "s3://sfc-eng-data/twitter/O1k/tweets/1.csv.gz" {
t.Fatalf("got %v as file", s0)
}
})
Expand Down Expand Up @@ -143,7 +144,7 @@ func TestPutWithInvalidToken(t *testing.T) {
t.Error(err)
}
defer func() {
assertNilF(t, f.Close())
assertNilF(t, f.Close())
}()
uploader := manager.NewUploader(client)
if _, err = uploader.Upload(context.Background(), &s3.PutObjectInput{
Expand Down Expand Up @@ -238,7 +239,7 @@ func TestPretendToPutButList(t *testing.T) {
}

func TestPutGetAWSStage(t *testing.T) {
if runningOnGithubAction() && !runningOnAWS() {
if runningOnGithubAction() || !runningOnAWS() {
t.Skip("skipping non aws environment")
}

Expand Down Expand Up @@ -275,7 +276,7 @@ func TestPutGetAWSStage(t *testing.T) {
sqlText := fmt.Sprintf(sql, strings.ReplaceAll(fname, "\\", "\\\\"), stageName)
rows := dbt.mustQuery(sqlText)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()

var s0, s1, s2, s3, s4, s5, s6, s7 string
Expand All @@ -292,7 +293,7 @@ func TestPutGetAWSStage(t *testing.T) {
sqlText = strings.ReplaceAll(sql, "\\", "\\\\")
rows = dbt.mustQuery(sqlText)
defer func() {
assertNilF(t, rows.Close())
assertNilF(t, rows.Close())
}()
for rows.Next() {
if err = rows.Scan(&s0, &s1, &s2, &s3); err != nil {
Expand Down Expand Up @@ -323,7 +324,7 @@ func TestPutGetAWSStage(t *testing.T) {
t.Error(err)
}
defer func() {
assertNilF(t, f.Close())
assertNilF(t, f.Close())
}()
gz, err := gzip.NewReader(f)
if err != nil {
Expand Down

0 comments on commit 09f4086

Please sign in to comment.