-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
292 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import Config | ||
|
||
config :edgedb, | ||
rended_colored_errors: false, | ||
file_module: Tests.Support.Mocks.FileMock, | ||
path_module: Tests.Support.Mocks.PathMock, | ||
system_module: Tests.Support.Mocks.SystemMock |
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
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,54 @@ | ||
defmodule Tests.ErrorTest do | ||
use Tests.Support.EdgeDBCase | ||
|
||
setup :edgedb_client | ||
|
||
@queries %{ | ||
"select $0" => """ | ||
QueryError: missing a type cast before the parameter | ||
┌─ query:1:8 | ||
│ | ||
1 │ select $0 | ||
│ ^^ error | ||
""", | ||
"select ('something', 42, 1 < 'kek😁lol/не англ');" => """ | ||
InvalidTypeError: operator '<' cannot be applied to operands of type 'std::int64' and 'std::str' | ||
┌─ query:1:26 | ||
│ | ||
1 │ select ('something', 42, 1 < 'kek😁lol/не англ'); | ||
│ ^^^^^^^^^^^^^^^^^^^^^^ Consider using an explicit type cast or a conversion function. | ||
""", | ||
""" | ||
select ( | ||
'something', 'not valid operand' < ( | ||
2, 3, 4, | ||
), 345 | ||
); | ||
""" => """ | ||
InvalidTypeError: operator '<' cannot be applied to operands of type 'std::str' and 'tuple<std::int64, std::int64, std::int64>' | ||
┌─ query:2:18 | ||
│ | ||
2 │ 'something', 'not valid operand' < ( | ||
│ ╭──────────────────^ | ||
3 │ │ 2, 3, 4, | ||
4 │ │ ), 345 | ||
│ ╰─────^ Consider using an explicit type cast or a conversion function. | ||
""", | ||
"select { x := 1 } { x := 'f̷͈͎͒̕ǫ̴̏͌ö̶̱̘' };" => """ | ||
SchemaError: cannot redefine property 'x' of object type 'std::FreeObject' as scalar type 'std::str' | ||
┌─ query:1:26 | ||
│ | ||
1 │ select { x := 1 } { x := 'f̷͈͎͒̕ǫ̴̏͌ö̶̱̘' }; | ||
│ ^^^^^ error | ||
""" | ||
} | ||
|
||
for {query, message} <- @queries do | ||
message = String.trim(message) | ||
|
||
test "rendering error for #{inspect(query)} query", %{client: client} do | ||
assert {:error, %EdgeDB.Error{} = exc} = EdgeDB.query(client, unquote(query)) | ||
assert Exception.message(exc) == unquote(message) | ||
end | ||
end | ||
end |