Skip to content

Commit e0caa08

Browse files
committed
Remove shouldNotThrowAny from test where the returned value is used later
1 parent 4d4b8be commit e0caa08

File tree

3 files changed

+32
-45
lines changed

3 files changed

+32
-45
lines changed

json-schema-validator/src/commonTest/kotlin/io/github/optimumcode/json/schema/base/JsonSchemaLoaderTest.kt

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import io.github.optimumcode.json.schema.ValidationError
1313
import io.github.optimumcode.json.schema.model.AbstractElement
1414
import io.github.optimumcode.json.schema.model.PrimitiveElement
1515
import io.kotest.assertions.assertSoftly
16-
import io.kotest.assertions.throwables.shouldNotThrowAny
1716
import io.kotest.assertions.throwables.shouldNotThrowAnyUnit
1817
import io.kotest.assertions.throwables.shouldThrow
1918
import io.kotest.assertions.withClue
@@ -315,31 +314,29 @@ class JsonSchemaLoaderTest : FunSpec() {
315314
// https://github.com/OptimumCode/json-schema-validator/issues/87
316315
test("BUG_87 relative uri-ref in root \$id causes incorrect reference resolution for root schema") {
317316
val schema =
318-
shouldNotThrowAny {
319-
JsonSchemaLoader.create()
320-
.register(
321-
"""
322-
{
317+
JsonSchemaLoader.create()
318+
.register(
319+
"""
320+
{
321+
"${'$'}schema": "https://json-schema.org/draft/2020-12/schema",
322+
"${'$'}id": "myproject/enums/foo",
323+
"type": "integer"
324+
}
325+
""".trimIndent(),
326+
).fromDefinition(
327+
"""
328+
{
323329
"${'$'}schema": "https://json-schema.org/draft/2020-12/schema",
324-
"${'$'}id": "myproject/enums/foo",
325-
"type": "integer"
326-
}
327-
""".trimIndent(),
328-
).fromDefinition(
329-
"""
330-
{
331-
"${'$'}schema": "https://json-schema.org/draft/2020-12/schema",
332-
"${'$'}id": "myproject/data/request",
333-
"type": "object",
334-
"properties": {
335-
"foobar": {
336-
"${'$'}ref": "/myproject/enums/foo"
337-
}
338-
}
339-
}
340-
""".trimIndent(),
341-
)
342-
}
330+
"${'$'}id": "myproject/data/request",
331+
"type": "object",
332+
"properties": {
333+
"foobar": {
334+
"${'$'}ref": "/myproject/enums/foo"
335+
}
336+
}
337+
}
338+
""".trimIndent(),
339+
)
343340

344341
val errors = mutableListOf<ValidationError>()
345342
val valid =

json-schema-validator/src/commonTest/kotlin/io/github/optimumcode/json/schema/extension/JsonSchemaExtensionTest.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import io.github.optimumcode.json.schema.ValidationError
88
import io.github.optimumcode.json.schema.model.AbstractElement
99
import io.github.optimumcode.json.schema.model.PrimitiveElement
1010
import io.kotest.assertions.assertSoftly
11-
import io.kotest.assertions.throwables.shouldNotThrowAny
1211
import io.kotest.assertions.throwables.shouldThrow
1312
import io.kotest.assertions.withClue
1413
import io.kotest.core.spec.style.FunSpec
@@ -98,23 +97,19 @@ class JsonSchemaExtensionTest : FunSpec() {
9897

9998
test("registers all extensions with varargs") {
10099
val schema =
101-
shouldNotThrowAny {
102-
JsonSchemaLoader
103-
.create()
104-
.withExtensions(SimpleTimeFormatAssertionFactory, SimpleDateFormatAssertionFactory)
105-
.fromDefinition(schemaDef)
106-
}
100+
JsonSchemaLoader
101+
.create()
102+
.withExtensions(SimpleTimeFormatAssertionFactory, SimpleDateFormatAssertionFactory)
103+
.fromDefinition(schemaDef)
107104
checkValidAndInvalid(schema)
108105
}
109106

110107
test("registers all extensions with iterable") {
111108
val schema =
112-
shouldNotThrowAny {
113-
JsonSchemaLoader
114-
.create()
115-
.withExtensions(listOf(SimpleTimeFormatAssertionFactory, SimpleDateFormatAssertionFactory))
116-
.fromDefinition(schemaDef)
117-
}
109+
JsonSchemaLoader
110+
.create()
111+
.withExtensions(listOf(SimpleTimeFormatAssertionFactory, SimpleDateFormatAssertionFactory))
112+
.fromDefinition(schemaDef)
118113
checkValidAndInvalid(schema)
119114
}
120115
}

test-suites/src/commonTest/kotlin/io/github/optimumcode/json/schema/suite/AbstractSchemaTestSuite.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import io.github.optimumcode.json.schema.JsonSchema
88
import io.github.optimumcode.json.schema.JsonSchemaLoader
99
import io.github.optimumcode.json.schema.SchemaOption
1010
import io.github.optimumcode.json.schema.SchemaType
11-
import io.kotest.assertions.throwables.shouldNotThrowAny
1211
import io.kotest.assertions.withClue
1312
import io.kotest.core.spec.style.FunSpec
1413
import io.kotest.matchers.shouldBe
@@ -235,12 +234,8 @@ private fun FunSpec.executeFromDirectory(
235234
test("$testSuiteID at index $testSuiteIndex test $testIndex") {
236235
withClue(listOf(testSuite.description, testSuite.schema, test.description, test.data)) {
237236
val schema: JsonSchema =
238-
shouldNotThrowAny {
239-
schemaLoader.fromJsonElement(testSuite.schema, schemaType)
240-
}
241-
shouldNotThrowAny {
242-
schema.validate(test.data, ErrorCollector.EMPTY)
243-
} shouldBe test.valid
237+
schemaLoader.fromJsonElement(testSuite.schema, schemaType)
238+
schema.validate(test.data, ErrorCollector.EMPTY) shouldBe test.valid
244239
}
245240
}
246241
}

0 commit comments

Comments
 (0)