Skip to content

Commit

Permalink
Enable "gel" feature in mainstream (#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix authored Dec 4, 2024
1 parent 9006c31 commit 99f8ace
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 38 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ name = "edgedb"
path = "src/main.rs"

[features]
default = ["gel"]
dev_mode = []
github_action_install = []
github_nightly = []
Expand Down
6 changes: 6 additions & 0 deletions tests/func/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ mod interactive;

mod help;

pub const BRANDING_CLI_CMD: &str = if cfg!(feature = "gel") {
"gel"
} else {
"edgedb"
};

fn edgedb_cli_cmd() -> assert_cmd::Command {
let mut cmd = Command::cargo_bin("edgedb").expect("binary found");

Expand Down
90 changes: 52 additions & 38 deletions tests/func/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{rm_migration_files, SERVER};
use crate::{rm_migration_files, BRANDING_CLI_CMD, SERVER};
use predicates::boolean::PredicateBooleanExt;
use predicates::str::{contains, ends_with};
use std::fs;
Expand All @@ -22,7 +22,9 @@ fn bare_status() {
.assert()
.code(2)
.stderr(contains("CREATE PROPERTY field1"))
.stderr(contains("edgedb error: Some migrations are missing"));
.stderr(contains(format!(
"{BRANDING_CLI_CMD} error: Some migrations are missing"
)));
}

#[test]
Expand All @@ -44,10 +46,10 @@ fn initial() {
.arg("--schema-dir=tests/migrations/db1/initial")
.assert()
.code(3)
.stderr(ends_with(
"edgedb error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `edgedb migrate` to apply.\n",
));
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `{BRANDING_CLI_CMD} migrate` to apply.\n"
)));
SERVER
.admin_cmd()
.arg("--branch=initial")
Expand All @@ -65,12 +67,12 @@ fn initial() {
.arg("--schema-dir=tests/migrations/db1/initial")
.assert()
.code(1)
.stderr(ends_with(
"edgedb error: Database must be updated \
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database must be updated \
to the last migration on the filesystem for `migration create`. \
Run:\n \
edgedb migrate\n",
));
{BRANDING_CLI_CMD} migrate\n",
)));
SERVER
.admin_cmd()
.arg("--branch=initial")
Expand Down Expand Up @@ -276,10 +278,10 @@ fn project() {
.current_dir("tests/migrations/db1/project")
.assert()
.code(3)
.stderr(ends_with(
"edgedb error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `edgedb migrate` to apply.\n",
));
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `{BRANDING_CLI_CMD} migrate` to apply.\n",
)));
SERVER
.admin_cmd()
.arg("--branch=project")
Expand All @@ -297,12 +299,12 @@ fn project() {
.current_dir("tests/migrations/db1/project")
.assert()
.code(1)
.stderr(ends_with(
"edgedb error: Database must be updated \
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database must be updated \
to the last migration on the filesystem for `migration create`. \
Run:\n \
edgedb migrate\n",
));
{BRANDING_CLI_CMD} migrate\n",
)));
SERVER
.admin_cmd()
.arg("--branch=project")
Expand Down Expand Up @@ -497,10 +499,10 @@ fn modified1() {
.arg("--schema-dir=tests/migrations/db1/modified1")
.assert()
.code(3)
.stderr(ends_with(
"edgedb error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `edgedb migrate` to apply.\n",
));
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database is empty, while 1 migrations \
have been found in the filesystem.\n Run `{BRANDING_CLI_CMD} migrate` to apply.\n",
)));
SERVER
.admin_cmd()
.arg("--branch=modified1")
Expand All @@ -510,12 +512,12 @@ fn modified1() {
.arg("--schema-dir=tests/migrations/db1/modified1")
.assert()
.code(1)
.stderr(ends_with(
"edgedb error: Database must be updated \
.stderr(ends_with(format!(
"{BRANDING_CLI_CMD} error: Database must be updated \
to the last migration on the filesystem for `migration create`. \
Run:\n \
edgedb migrate\n",
));
{BRANDING_CLI_CMD} migrate\n",
)));
SERVER
.admin_cmd()
.arg("--branch=modified1")
Expand All @@ -537,7 +539,9 @@ fn modified1() {
.assert()
.code(2)
.stderr(contains("CREATE PROPERTY field2"))
.stderr(contains("edgedb error: Some migrations are missing"));
.stderr(contains(format!(
"{BRANDING_CLI_CMD} error: Some migrations are missing"
)));
SERVER
.admin_cmd()
.arg("--branch=modified1")
Expand Down Expand Up @@ -785,7 +789,7 @@ fn extract01() {
.failure()
.stderr(
contains("Writing")
.and(contains("edgedb error: Cannot write"))
.and(contains(format!("{BRANDING_CLI_CMD} error: Cannot write")))
.and(contains("\n Caused by: failed to copy file from"))
.and(contains("\n Caused by: Permission denied")),
);
Expand All @@ -801,36 +805,42 @@ fn error() {
.assert()
.success();
let err = if SERVER.0.version_major >= 6 {
r###"error: Unexpected keyword 'CREATE'
format!(
r###"error: Unexpected keyword 'CREATE'
┌─ tests/migrations/db1/error/bad.esdl:3:9
3 │ create property text -> str;
│ ^^^^^^ Use a different identifier or quote the name with backticks: `create`
= This name is a reserved keyword and cannot be used as an identifier
edgedb error: cannot proceed until schema files are fixed
{BRANDING_CLI_CMD} error: cannot proceed until schema files are fixed
"###
)
} else if SERVER.0.version_major >= 4 {
r###"error: Unexpected keyword 'CREATE'
format!(
r###"error: Unexpected keyword 'CREATE'
┌─ tests/migrations/db1/error/bad.esdl:3:9
3 │ create property text -> str;
│ ^^^^^^ Use a different identifier or quote the name with backticks: `create`
= This name is a reserved keyword and cannot be used as an identifier
edgedb error: cannot proceed until .esdl files are fixed
{BRANDING_CLI_CMD} error: cannot proceed until .esdl files are fixed
"###
)
} else {
r###"error: Unexpected keyword 'CREATE'
format!(
r###"error: Unexpected keyword 'CREATE'
┌─ tests/migrations/db1/error/bad.esdl:3:9
3 │ create property text -> str;
│ ^^^^^^ error
edgedb error: cannot proceed until .esdl files are fixed
{BRANDING_CLI_CMD} error: cannot proceed until .esdl files are fixed
"###
)
};
SERVER
.admin_cmd()
Expand Down Expand Up @@ -1083,27 +1093,31 @@ fn input_required() {
#[test]
fn eof_err() {
let err = if SERVER.0.version_major >= 6 {
r###"error: Missing '{'
format!(
r###"error: Missing '{{'
┌─ tests/migrations/db_eof_err/default.esdl:9:19
9 │ alias default::Foo
│ ╭──────────────────^
10 │ │
│ ╰^ error
edgedb error: cannot proceed until schema files are fixed
{BRANDING_CLI_CMD} error: cannot proceed until schema files are fixed
"###
)
} else {
r###"error: Missing '{'
format!(
r###"error: Missing '{{'
┌─ tests/migrations/db_eof_err/default.esdl:9:19
9 │ alias default::Foo
│ ╭──────────────────^
10 │ │
│ ╰^ error
edgedb error: cannot proceed until .esdl files are fixed
{BRANDING_CLI_CMD} error: cannot proceed until .esdl files are fixed
"###
)
};
SERVER
.admin_cmd()
Expand Down

0 comments on commit 99f8ace

Please sign in to comment.