Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cgardens committed Jun 20, 2022
1 parent dd63a61 commit 9593baf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
import io.airbyte.server.helpers.SourceDefinitionHelpers;
import io.airbyte.server.helpers.SourceHelpers;
import io.airbyte.validation.json.JsonValidationException;
import io.airbyte.workers.helper.ConnectionHelper;
import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Instant;
Expand All @@ -109,7 +108,6 @@ class WebBackendConnectionsHandlerTest {
private WebBackendConnectionRead expected;
private WebBackendConnectionRead expectedWithNewSchema;
private EventRunner eventRunner;
private ConnectionHelper connectionHelper;
private ConfigRepository configRepository;

@BeforeEach
Expand All @@ -122,7 +120,6 @@ public void setup() throws IOException, JsonValidationException, ConfigNotFoundE
configRepository = mock(ConfigRepository.class);
schedulerHandler = mock(SchedulerHandler.class);
eventRunner = mock(EventRunner.class);
connectionHelper = mock(ConnectionHelper.class);
wbHandler = new WebBackendConnectionsHandler(connectionsHandler,
sourceHandler,
destinationHandler,
Expand Down Expand Up @@ -233,7 +230,9 @@ public void setup() throws IOException, JsonValidationException, ConfigNotFoundE
.latestSyncJobStatus(expected.getLatestSyncJobStatus())
.isSyncing(expected.getIsSyncing())
.catalogDiff(new CatalogDiff().transforms(List.of(
new StreamTransform().transformType(TransformTypeEnum.REMOVE_STREAM).removeStream(new StreamDescriptor().name("users-data1")))))
new StreamTransform().transformType(TransformTypeEnum.ADD_STREAM)
.addStream(new StreamDescriptor().name("users-data1"))
.updateStream(null))))
.resourceRequirements(new ResourceRequirements()
.cpuRequest(ConnectionHelpers.TESTING_RESOURCE_REQUIREMENTS.getCpuRequest())
.cpuLimit(ConnectionHelpers.TESTING_RESOURCE_REQUIREMENTS.getCpuLimit())
Expand Down Expand Up @@ -473,10 +472,12 @@ public void testForConnectionCreateCompleteness() {
.collect(Collectors.toSet());

final String message =
"If this test is failing, it means you added a field to ConnectionCreate!\nCongratulations, but you're not done yet..\n"
+ "\tYou should update WebBackendConnectionsHandler::toConnectionCreate\n"
+ "\tand ensure that the field is tested in WebBackendConnectionsHandlerTest::testToConnectionCreate\n"
+ "Then you can add the field name here to make this test pass. Cheers!";
"""
If this test is failing, it means you added a field to ConnectionCreate!
Congratulations, but you're not done yet..
\tYou should update WebBackendConnectionsHandler::toConnectionCreate
\tand ensure that the field is tested in WebBackendConnectionsHandlerTest::testToConnectionCreate
Then you can add the field name here to make this test pass. Cheers!""";
assertEquals(handledMethods, methods, message);
}

Expand All @@ -492,10 +493,12 @@ public void testForConnectionUpdateCompleteness() {
.collect(Collectors.toSet());

final String message =
"If this test is failing, it means you added a field to ConnectionUpdate!\nCongratulations, but you're not done yet..\n"
+ "\tYou should update WebBackendConnectionsHandler::toConnectionUpdate\n"
+ "\tand ensure that the field is tested in WebBackendConnectionsHandlerTest::testToConnectionUpdate\n"
+ "Then you can add the field name here to make this test pass. Cheers!";
"""
If this test is failing, it means you added a field to ConnectionUpdate!
Congratulations, but you're not done yet..
\tYou should update WebBackendConnectionsHandler::toConnectionUpdate
\tand ensure that the field is tested in WebBackendConnectionsHandlerTest::testToConnectionUpdate
Then you can add the field name here to make this test pass. Cheers!""";
assertEquals(handledMethods, methods, message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

public class ConnectionHelpers {

private static final String STREAM_NAME = "users-data";
private static final String STREAM_NAME_BASE = "users-data";
private static final String STREAM_NAME = STREAM_NAME_BASE + "0";
private static final String FIELD_NAME = "id";
private static final String BASIC_SCHEDULE_TIME_UNIT = "days";
private static final long BASIC_SCHEDULE_UNITS = 1L;
Expand Down Expand Up @@ -200,7 +201,7 @@ private static io.airbyte.protocol.models.AirbyteStream generateBasicAirbyteStre

public static AirbyteCatalog generateBasicApiCatalog() {
return new AirbyteCatalog().streams(Lists.newArrayList(new AirbyteStreamAndConfiguration()
.stream(generateBasicApiStream(String.valueOf(1)))
.stream(generateBasicApiStream(null))
.config(generateBasicApiStreamConfig())));
}

Expand Down Expand Up @@ -230,7 +231,7 @@ private static AirbyteStream generateBasicApiStream() {

private static AirbyteStream generateBasicApiStream(final String nameSuffix) {
return new AirbyteStream()
.name(STREAM_NAME + (nameSuffix == null ? "" : nameSuffix))
.name(nameSuffix == null ? STREAM_NAME : STREAM_NAME_BASE + nameSuffix)
.jsonSchema(generateBasicJsonSchema())
.defaultCursorField(Lists.newArrayList(FIELD_NAME))
.sourceDefinedCursor(false)
Expand Down

0 comments on commit 9593baf

Please sign in to comment.