Skip to content

Commit

Permalink
test: CleanupModeTest.parse uses @ParameterizedTest instead of 'for' …
Browse files Browse the repository at this point in the history
…loop

Signed-off-by: Harsh4902 <[email protected]>
  • Loading branch information
Harsh4902 authored Sep 2, 2024
1 parent 121c427 commit c6178e3
Showing 1 changed file with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
package org.eclipse.jkube.kit.config.image.build;

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 java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
Expand All @@ -27,21 +32,21 @@
*/
class CleanupModeTest {

@Test
void parse() {

Object[] data = {
null, TRY_TO_REMOVE,
"try", TRY_TO_REMOVE,
"FaLsE", NONE,
"NONE", NONE,
"true", REMOVE,
"removE", REMOVE
};
@ParameterizedTest
@MethodSource("provideParseTestData")
void parse(String input, CleanupMode expected) {
assertThat(CleanupMode.parse(input)).isEqualTo(expected);
}

for (int i = 0; i < data.length; i += 2) {
assertThat(CleanupMode.parse((String) data[i])).isEqualTo(data[i + 1]);
}
static Stream<Arguments> provideParseTestData() {
return Stream.of(
Arguments.of(null, CleanupMode.TRY_TO_REMOVE),
Arguments.of("try", CleanupMode.TRY_TO_REMOVE),
Arguments.of("FaLsE", CleanupMode.NONE),
Arguments.of("NONE", CleanupMode.NONE),
Arguments.of("true", CleanupMode.REMOVE),
Arguments.of("removE", CleanupMode.REMOVE)
);
}

@Test
Expand Down

0 comments on commit c6178e3

Please sign in to comment.