Skip to content

Commit 7faaf0b

Browse files
authored
Merge pull request #150 from graphql-java/add-new-test-cases
Add more DateTime test cases from specification
2 parents 4f30d8f + 7c2c1d3 commit 7faaf0b

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

src/test/groovy/graphql/scalars/datetime/DateTimeScalarTest.groovy

+28-12
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ class DateTimeScalarTest extends Specification {
6060
then:
6161
thrown(expectedValue)
6262
where:
63-
input | expectedValue
64-
"1985-04-12" | CoercingParseValueException
65-
"2022-11-24T01:00:01.02-00:00" | CoercingParseValueException
66-
mkLocalDT(year: 1980, hour: 3) | CoercingParseValueException
67-
666 || CoercingParseValueException
63+
input | expectedValue
64+
"1985-04-12" | CoercingParseValueException // No time provided
65+
"2022-11-24T01:00:01.02-00:00" | CoercingParseValueException // -00:00 is not a valid offset in specification
66+
mkLocalDT(year: 1980, hour: 3) | CoercingParseValueException // LocalDateTime has no time zone
67+
666 | CoercingParseValueException // A random number
68+
"2011-08-30T13:22:53.108" | CoercingParseValueException // No offset provided
69+
"2011-08-30T24:22:53.108Z" | CoercingParseValueException // 24 is not allowed as hour of the time
70+
"2010-02-30T21:22:53.108Z" | CoercingParseValueException // 30th of February is not a valid date
71+
"2010-02-11T21:22:53.108Z+25:11" | CoercingParseValueException // 25 is not a valid hour for offset
6872
}
6973

7074
def "datetime AST literal"() {
@@ -101,11 +105,15 @@ class DateTimeScalarTest extends Specification {
101105
then:
102106
thrown(expectedValue)
103107
where:
104-
input | expectedValue
105-
"1985-04-12" | CoercingSerializeException
106-
"2022-11-24T01:00:01.02-00:00" | CoercingSerializeException
107-
mkLocalDT(year: 1980, hour: 3) | CoercingSerializeException
108-
666 || CoercingSerializeException
108+
input | expectedValue
109+
"1985-04-12" | CoercingSerializeException // No time provided
110+
"2022-11-24T01:00:01.02-00:00" | CoercingSerializeException // -00:00 is not a valid offset in specification
111+
mkLocalDT(year: 1980, hour: 3) | CoercingSerializeException // LocalDateTime has no time zone
112+
666 | CoercingSerializeException // A random number
113+
"2011-08-30T13:22:53.108" | CoercingSerializeException // No offset provided
114+
"2011-08-30T24:22:53.108Z" | CoercingSerializeException // 24 is not allowed as hour of the time
115+
"2010-02-30T21:22:53.108Z" | CoercingSerializeException // 30th of February is not a valid date
116+
"2010-02-11T21:22:53.108Z+25:11" | CoercingSerializeException // 25 is not a valid hour for offset
109117
}
110118

111119
@Unroll
@@ -116,8 +124,16 @@ class DateTimeScalarTest extends Specification {
116124
then:
117125
thrown(expectedValue)
118126
where:
119-
input | expectedValue
120-
"2022-11-24T01:00:01.02-00:00" | CoercingParseLiteralException
127+
input | expectedValue
128+
"2022-11-24T01:00:01.02-00:00" | CoercingParseLiteralException // -00:00 is not a valid offset in specification
129+
"1985-04-12" | CoercingParseLiteralException // No time provided
130+
"2022-11-24T01:00:01.02-00:00" | CoercingParseLiteralException // -00:00 is not a valid offset in specification
131+
mkLocalDT(year: 1980, hour: 3) | CoercingParseLiteralException // LocalDateTime has no time zone
132+
666 | CoercingParseLiteralException // A random number
133+
"2011-08-30T13:22:53.108" | CoercingParseLiteralException // No offset provided
134+
"2011-08-30T24:22:53.108Z" | CoercingParseLiteralException // 24 is not allowed as hour of the time
135+
"2010-02-30T21:22:53.108Z" | CoercingParseLiteralException // 30th of February is not a valid date
136+
"2010-02-11T21:22:53.108Z+25:11" | CoercingParseLiteralException // 25 is not a valid hour for offset
121137
}
122138

123139
}

0 commit comments

Comments
 (0)