-
-
Notifications
You must be signed in to change notification settings - Fork 804
Expand file tree
/
Copy pathErrorGeneratorTests.cs
More file actions
70 lines (64 loc) · 2.16 KB
/
ErrorGeneratorTests.cs
File metadata and controls
70 lines (64 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using static StrawberryShake.CodeGeneration.CSharp.GeneratorTestHelper;
namespace StrawberryShake.CodeGeneration.CSharp;
public class ErrorGeneratorTests
{
[Fact]
public void Generate_NoErrors()
{
AssertResult(
FileResource.Open("Query.graphql"),
FileResource.Open("Schema.extensions.graphql"),
FileResource.Open("Schema.graphql"));
}
[Fact]
public void Generate_SyntaxError()
{
Assert.Collection(
AssertError(
Path.Combine("__resources__", "Query_SyntaxError.graphql"),
Path.Combine("__resources__", "Schema.extensions.graphql"),
Path.Combine("__resources__", "Schema.graphql")),
error =>
{
Assert.Equal("SS0001", error.Code);
Assert.Equal(
"Expected a `RightBrace`-token, but found a `EndOfFile`-token.",
error.Message);
});
}
[Fact]
public void Generate_SchemaValidationError()
{
Assert.Collection(
AssertError(
Path.Combine("__resources__", "Query_SchemaValidationError.graphql"),
Path.Combine("__resources__", "Schema.extensions.graphql"),
Path.Combine("__resources__", "Schema.graphql")),
error =>
{
Assert.Equal("SS0002", error.Code);
Assert.Equal(
"The field `someNotExistingField` does not exist on the type `Character`.",
error.Message);
});
}
[Fact]
public void Generate_ChatClient_InvalidNullCheck()
{
AssertResult(
FileResource.Open("ChatMeFiendsNodes.graphql"),
FileResource.Open("Schema.extensions.graphql"),
FileResource.Open("ChatSchema.graphql"));
}
// TODO : this is a bug with the code generation.
/*
[Fact]
public void ClosePaymentsMutationErrors()
{
AssertResult(
FileResource.Open("PaymentSchema.graphql"),
FileResource.Open("Schema.extensions.graphql"),
FileResource.Open("PaymentQuery.graphql"));
}
*/
}