Skip to content

Commit 9bf76db

Browse files
authored
test: do not rely on the datasource url in tests (#5644)
[TML-1464](https://linear.app/prisma-company/issue/TML-1463/rewrite-prisma-engines-tests-to-bypass-envtest-database-url) Makes sure that the vast majority of our tests no longer rely on the datasource url attribute and replaces the URLs with a dummy `dummy-url`. The exceptions: - `schema-engine/cli/tests/cli_tests.rs` - 8 tests in this file manually spawn the schema engine binary, currently there is no way to pass the URL to it - `execute_postgres` - `introspect_single_postgres_force` - `introspect_multi_postgres_force` - `get_database_version_multi_file` - `introspect_sqlite_empty_database` - `introspect_sqlite_invalid_empty_database` - `basic_jsonrpc_roundtrip_works_with_no_params` - `basic_jsonrpc_roundtrip_works_with_params` - `schema-engine/sql-migration-tests/tests/migrations/postgres.rs` - one test programatically instantiates the schema engine, currently there is no way to pass the URL to it - `connecting_to_a_postgres_database_with_the_cockroach_connector_fails` - `query-engine/black-box-tests` - 4 tests in this directory manually spawn the query engine binary, currently there is no way to pass the URL to it - current workaround: https://github.com/prisma/prisma-engines/blob/69604b598fc4df42ba275353886e48ad742a30e3/query-engine/connector-test-kit-rs/query-tests-setup/src/datamodel_rendering/mod.rs#L53 In the case of all these tests, they still rely on the URL attribute, they could be modified to pass the URL through RPC pretty easily though since they directly use RPC commands (which would require us to actually implement something like that in the RPC and I think we will need something like that in Prisma 7, it's currently not possible). The main changes are split into two commits, the first adjusts the test code and the second replaces all TEST_DATABASE_URL with a dummy value (to verify they're not used).
1 parent 4a38451 commit 9bf76db

192 files changed

Lines changed: 503 additions & 512 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prisma-fmt/tests/code_actions/scenarios/multi_schema_one_model/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ generator client {
55

66
datasource db {
77
provider = "postgresql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
schemas = ["one", "two"]
1010
}
1111

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
datasource db {
22
provider = "postgresql"
3-
url = env("TEST_DATABASE_URL")
3+
url = "dummy-url"
44
schemas = ["one", "two"]
55
}

prisma-fmt/tests/code_actions/scenarios/multi_schema_one_model_one_enum/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ generator client {
55

66
datasource db {
77
provider = "postgresql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
schemas = ["one", "two"]
1010
}
1111

prisma-fmt/tests/code_actions/scenarios/multi_schema_one_model_one_enum_multifile/config.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ generator client {
55

66
datasource db {
77
provider = "postgresql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
schemas = ["one", "two"]
1010
}

prisma-fmt/tests/code_actions/scenarios/multi_schema_two_models/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ generator client {
55

66
datasource db {
77
provider = "postgresql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
schemas = ["one", "two"]
1010
}
1111

prisma-fmt/tests/code_actions/scenarios/multi_schema_two_models_relation_mode/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ generator client {
55

66
datasource db {
77
provider = "postgresql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
relationMode = "prisma"
1010
schemas = ["one", "two"]
1111
}

prisma-fmt/tests/code_actions/scenarios/relation_mode_prisma_missing_index/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ generator client {
55

66
datasource db {
77
provider = "mysql"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
relationMode = "prisma"
1010
}
1111

prisma-fmt/tests/code_actions/scenarios/relation_mode_prisma_missing_index_multifile/config.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ generator client {
44

55
datasource db {
66
provider = "mysql"
7-
url = env("TEST_DATABASE_URL")
7+
url = "dummy-url"
88
relationMode = "prisma"
99
}

prisma-fmt/tests/native_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn test_native_types_list_on_crdb() {
55
let schema = r#"
66
datasource mydb {
77
provider = "cockroachdb"
8-
url = env("TEST_DATABASE_URL")
8+
url = "dummy-url"
99
}
1010
"#;
1111

@@ -24,7 +24,7 @@ fn test_native_types_multifile() {
2424
r#"
2525
datasource mydb {
2626
provider = "postgresql"
27-
url = env("TEST_DATABASE_URL")
27+
url = "dummy-url"
2828
}"#,
2929
),
3030
(

0 commit comments

Comments
 (0)