Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch committed Oct 4, 2023
1 parent b2dd1fc commit ebbb40a
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import io.servicetalk.concurrent.test.internal.TestPublisherSubscriber;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static io.servicetalk.concurrent.api.Publisher.from;
import static io.servicetalk.concurrent.api.SourceAdapters.toSource;
Expand All @@ -38,9 +40,23 @@ void errorPassThrough() {
}

@Test
void completeToError() {
void nullCompletes() {
toSource(Publisher.<Integer>empty()
.onCompleteError(() -> null)
).subscribe(subscriber);
subscriber.awaitOnComplete();
}

@ParameterizedTest(name = "{displayName} [{index}] shouldThrow={0}")
@ValueSource(booleans = {false, true})
void completeToError(boolean shouldThrow) {
toSource(from(1)
.onCompleteError(() -> DELIBERATE_EXCEPTION)
.onCompleteError(() -> {
if (shouldThrow) {
throw DELIBERATE_EXCEPTION;
}
return DELIBERATE_EXCEPTION;
})
).subscribe(subscriber);
subscriber.awaitSubscription().request(1);
assertThat(subscriber.takeOnNext(), equalTo(1));
Expand Down

0 comments on commit ebbb40a

Please sign in to comment.