Don't download MaxMind dbs in tests
Some checks failed
Deploy API / docker (17, 3.8.5) (push) Failing after 23s

This commit is contained in:
Braydon 2024-04-22 22:59:04 -04:00
parent f3a57dc8d9
commit 81886fa097
2 changed files with 21 additions and 2 deletions

@ -35,8 +35,23 @@ public final class EnvironmentUtils {
* Is the app running in a production environment?
*/
@Getter private static final boolean production;
static { // Are we running on production?
/**
* Is the app running in a test environment?
*/
@Getter private static boolean testing;
static {
// Are we running on production?
String env = System.getenv("APP_ENV");
production = env != null && (env.equals("production"));
// Are we running in a test?
try {
Class.forName("org.junit.Test");
testing = true;
} catch (ClassNotFoundException ignored) {
// Safely ignore
}
}
}

@ -30,6 +30,7 @@ import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.*;
import lombok.extern.log4j.Log4j2;
import me.braydon.mc.common.EnvironmentUtils;
import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.archiver.tar.TarGZipUnArchiver;
import org.springframework.beans.factory.annotation.Value;
@ -70,7 +71,10 @@ public final class MaxMindService {
@PostConstruct
public void onInitialize() {
loadDatabases(); // Load the databases
// Load the databases
if (!EnvironmentUtils.isTesting()) {
loadDatabases();
}
}
/**