Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
Check that MongoDB Dev Services are not started when either
`quarkus.mongodb.connection-string` or `quarkus.mongodb.hosts` are
present.

To prevent regressions, this integration test ensures that Dev Services
are actually started (by checking the appropriate properties) for the
default client.
  • Loading branch information
danilopiazza committed Jan 1, 2025
1 parent 8f11bb6 commit 624d6ad
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
quarkus.mongodb.parameter-injection.write-concern.journal=true

quarkus.mongodb.with-connection-string.connection-string=mongodb://localhost:27017

quarkus.mongodb.with-hosts.hosts=localhost:27017
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.quarkus.it.mongodb;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.not;

import jakarta.inject.Inject;

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

import com.mongodb.client.MongoClient;

import io.quarkus.mongodb.MongoClientName;
import io.quarkus.test.common.DevServicesContext;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.mongodb.MongoTestResource;

@QuarkusTest
@QuarkusTestResource(value = MongoTestResource.class)
public class DevServicesStartTest {

DevServicesContext context;

@Inject
@MongoClientName("with-connection-string")
MongoClient clientWithConnectionString;

@Inject
@MongoClientName("with-hosts")
MongoClient clientWithHosts;

@ParameterizedTest
@ValueSource(strings = {
"quarkus.mongodb.with-connection-string.connection-string",
"quarkus.mongodb.with-hosts.connection-string"
})
public void testDevServicesNotStarted(String property) {
assertThat(context.devServicesProperties(), not(hasKey(property)));
}

@Test
public void testDevServicesStarted() {
assertThat(context.devServicesProperties(), hasKey("quarkus.mongodb.connection-string"));
}
}

0 comments on commit 624d6ad

Please sign in to comment.