-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Optional switch for instrumentedsql (#2261)
- Loading branch information
1 parent
4d5d3ca
commit 9934a59
Showing
5 changed files
with
74 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package client | ||
|
||
import ( | ||
"database/sql" | ||
"os" | ||
"testing" | ||
|
||
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestNewClientWithoutInstrumentedSQL checks if the client is initialized with the different driver implementation. | ||
// This is dependent on the SF_TF_NO_INSTRUMENTED_SQL env variable setting. That's why it was extracted to another file. | ||
// To run this test use: `make test-client` command. | ||
func TestNewClientWithoutInstrumentedSQL(t *testing.T) { | ||
if os.Getenv("SF_TF_NO_INSTRUMENTED_SQL") == "" { | ||
t.Skip("Skipping TestNewClientWithoutInstrumentedSQL, because SF_TF_NO_INSTRUMENTED_SQL is not set") | ||
} | ||
|
||
t.Run("registers snowflake-not-instrumented driver", func(t *testing.T) { | ||
config := sdk.DefaultConfig() | ||
_, err := sdk.NewClient(config) | ||
require.NoError(t, err) | ||
|
||
assert.NotContains(t, sql.Drivers(), "snowflake-instrumented") | ||
assert.Contains(t, sql.Drivers(), "snowflake") | ||
}) | ||
} |