Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests related to #1249 #1510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ package org.zalando.zally.ruleset.zalando
import org.assertj.core.api.Assertions
import org.intellij.lang.annotations.Language
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.zalando.zally.core.DefaultContextFactory
import java.util.stream.Stream

class EnumValueTypeTest {

private val rule = EnumValueTypeRule()

@Test
fun `fail validation if 'x-extensible-enum' has a 'string' type`() {
companion object {
@JvmStatic
fun nonStringTypes(): Stream<Arguments> = Stream.of(
Arguments.of("number", "1", "2"),
Arguments.of("integer", "1", "2"),
Arguments.of("boolean", "true", "false")
)
}

@ParameterizedTest
@MethodSource("nonStringTypes")
fun `fail validation if 'x-extensible-enum' has a non-'string' type`(nonStringType: String, value1: String, value2: String) {
@Language("YAML")
val spec = """
openapi: 3.0.1
Expand All @@ -26,11 +40,10 @@ class EnumValueTypeTest {
type: object
properties:
prop-1:
type: integer
type: $nonStringType
x-extensible-enum:
- 1
- 2
- 3
- $value1
- $value2

""".trimIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ExtensibleEnumRuleTest {
}

@Test
fun `checkForEnums should return violation if no enums are used`() {
fun `checkForEnums should return no violation if no enums are used`() {
val content = """
openapi: 3.0.1
components:
Expand Down
Loading