Skip to content

Commit

Permalink
SNOW-499317 Fix panic when disable telemetry enabled (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jbahk authored Nov 8, 2021
1 parent d2c78da commit 8ca3bb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func buildSnowflakeConn(ctx context.Context, config Config) (*snowflakeConn, err
tokenAccessor = getSimpleTokenAccessor()
}
if sc.cfg.DisableTelemetry {
sc.telemetry.enabled = false
sc.telemetry = &snowflakeTelemetry{enabled: false}
}

// authenticate
Expand Down
15 changes: 15 additions & 0 deletions telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,18 @@ func TestTelemetrySQLException(t *testing.T) {
t.Errorf("there should be no telemetry data in log. found: %v", len(st.logs))
}
}

func TestDisableTelemetry(t *testing.T) {
config, _ := ParseDSN(dsn)
config.DisableTelemetry = true
sc, err := buildSnowflakeConn(context.Background(), *config)
if err != nil {
t.Fatal(err)
}
if err = authenticateWithConfig(sc); err != nil {
t.Fatal(err)
}
if _, err = sc.Query("select 1", nil); err != nil {
t.Fatal(err)
}
}

0 comments on commit 8ca3bb1

Please sign in to comment.