Skip to content

Commit

Permalink
[DAT-18785] Fix test setup, handle case when connection isn't establi…
Browse files Browse the repository at this point in the history
…shed.
  • Loading branch information
abrackx committed Oct 4, 2024
1 parent 1881378 commit f81d6a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@ public String getDatabaseProductName() {

@Override
public String getDatabaseProductVersion() {
Document document = getMongoDatabase().runCommand(new Document("buildInfo",1));
return document.getString("version") != null ? document.getString("version") : "Unknown";
String unknownVersion = "Unknown";
try {
Document document = getMongoDatabase().runCommand(new Document("buildInfo", 1));
String version = document.getString("version");
return version != null ? version : unknownVersion;
} catch (Exception unableToDetermineVersion) {
Scope.getCurrentScope().getLog(getClass()).warning("Unable to determine mongo database version!", unableToDetermineVersion);
return unknownVersion;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public abstract class AbstractMongoChangeTest {

@BeforeEach
void setUp() {
database = new MongoLiquibaseDatabase();
database = new MongoLiquibaseDatabase() {
@Override
public String getDatabaseProductVersion() {
return "test";
}
};
}
}

0 comments on commit f81d6a7

Please sign in to comment.