Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 9 additions & 27 deletions prisma-fmt/src/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,10 @@
];

let request = json!({
"prismaSchema": schemas,

Check warning on line 222 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
});

let expected = expect![[
r#"{"config":{"generators":[{"name":"js","provider":{"fromEnvVar":null,"value":"prisma-client"},"output":null,"config":{},"binaryTargets":[],"previewFeatures":[],"sourceFilePath":"generator.prisma"}],"datasources":[{"name":"db","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":null,"value":"postgresql://example.com/db"},"schemas":[],"sourceFilePath":"datasource.prisma"}],"warnings":[]},"errors":[]}"#
]];
let expected = expect![[r#"{"config":{"generators":[{"name":"js","provider":{"fromEnvVar":null,"value":"prisma-client"},"output":null,"config":{},"binaryTargets":[],"previewFeatures":[],"sourceFilePath":"generator.prisma"}],"datasources":[{"name":"db","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":null,"value":"postgresql://example.com/db"},"schemas":[],"sourceFilePath":"datasource.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -238,12 +236,10 @@
}
"#;

let request = json!({

Check warning on line 239 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
"prismaSchema": schema,
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mEnvironment variable not found: NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:4\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 3 | \u001b[0m provider = \"postgresql\"\n\u001b[1;94m 4 | \u001b[0m url = \u001b[1;91menv(\"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mEnvironment variable not found: NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:4\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 3 | \u001b[0m provider = \"postgresql\"\n\u001b[1;94m 4 | \u001b[0m url = \u001b[1;91menv(\"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -258,12 +254,10 @@
"#;

let request = json!({
"prismaSchema": schema,

Check warning on line 257 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
"ignoreEnvVarErrors": true,
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"NON_EXISTING_ENV_VAR_WE_COUNT_ON_IT_AT_LEAST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -280,12 +274,10 @@
let request = json!({
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb"

Check warning on line 277 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -303,12 +295,10 @@
let request = json!({
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb"

Check warning on line 298 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"directUrl":{"fromEnvVar":null,"value":"postgresql://example.com/direct"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"directUrl":{"fromEnvVar":null,"value":"postgresql://example.com/direct"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information.","The datasource attribute \"directUrl\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -327,12 +317,10 @@
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb",
"DBDIRURL": "postgresql://example.com/direct"

Check warning on line 320 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"directUrl":{"fromEnvVar":"DBDIRURL","value":"postgresql://example.com/direct"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":"postgresql://example.com/mydb"},"directUrl":{"fromEnvVar":"DBDIRURL","value":"postgresql://example.com/direct"},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information.","The datasource attribute \"directUrl\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -350,12 +338,10 @@
let request = json!({
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb",

Check warning on line 341 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":null,"value":""},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError validating datasource `thedb`: You must provide a nonempty direct URL\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91m\"\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":null,"value":""},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information.","The datasource attribute \"directUrl\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError validating datasource `thedb`: You must provide a nonempty direct URL\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91m\"\"\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -373,12 +359,10 @@
let request = json!({
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb",

Check warning on line 362 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":"DOES_NOT_EXIST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mEnvironment variable not found: DOES_NOT_EXIST.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91menv(\"DOES_NOT_EXIST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":"DOES_NOT_EXIST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information.","The datasource attribute \"directUrl\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mEnvironment variable not found: DOES_NOT_EXIST.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91menv(\"DOES_NOT_EXIST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand All @@ -397,12 +381,10 @@
"prismaSchema": schema,
"env": {
"DBURL": "postgresql://example.com/mydb",
"DOES_NOT_EXIST": "",

Check warning on line 384 in prisma-fmt/src/get_config.rs

View workflow job for this annotation

GitHub Actions / run lints and formatting checks

Diff in /home/runner/work/prisma-engines/prisma-engines/prisma-fmt/src/get_config.rs
}
});
let expected = expect![[
r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":"DOES_NOT_EXIST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":[]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError validating datasource `thedb`: You must provide a nonempty direct URL. The environment variable `DOES_NOT_EXIST` resolved to an empty string.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91menv(\"DOES_NOT_EXIST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#
]];
let expected = expect![[r#"{"config":{"generators":[],"datasources":[{"name":"thedb","provider":"postgresql","activeProvider":"postgresql","url":{"fromEnvVar":"DBURL","value":null},"directUrl":{"fromEnvVar":"DOES_NOT_EXIST","value":null},"schemas":[],"sourceFilePath":"schema.prisma"}],"warnings":["The datasource attribute \"url\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information.","The datasource attribute \"directUrl\" is also available to the Prisma Config file, and will be removed from the datasource in Prisma 7.0.0. See https://pris.ly/prisma-config for more information."]},"errors":[{"file_name":"schema.prisma","message":"\u001b[1;91merror\u001b[0m: \u001b[1mError validating datasource `thedb`: You must provide a nonempty direct URL. The environment variable `DOES_NOT_EXIST` resolved to an empty string.\u001b[0m\n \u001b[1;94m-->\u001b[0m \u001b[4mschema.prisma:5\u001b[0m\n\u001b[1;94m | \u001b[0m\n\u001b[1;94m 4 | \u001b[0m url = env(\"DBURL\")\n\u001b[1;94m 5 | \u001b[0m directUrl = \u001b[1;91menv(\"DOES_NOT_EXIST\")\u001b[0m\n\u001b[1;94m | \u001b[0m\n"}]}"#]];
let response = get_config(&request.to_string());
expected.assert_eq(&response);
}
Expand Down
Loading
Loading