From fe3239249f83dfa2c06f21304fb593c55304fbed Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Fri, 5 Apr 2024 16:11:35 +0100 Subject: [PATCH] Only run integration tests if OPENAI_API_KEY is set --- .../io/github/stefanbratanov/jvm/openai/OpenAIModel.java | 8 ++++---- .../jvm/openai/OpenAIAssistantsApiIntegrationTest.java | 2 ++ .../stefanbratanov/jvm/openai/OpenAIIntegrationTest.java | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/stefanbratanov/jvm/openai/OpenAIModel.java b/src/main/java/io/github/stefanbratanov/jvm/openai/OpenAIModel.java index 38c6f21..8dce75c 100644 --- a/src/main/java/io/github/stefanbratanov/jvm/openai/OpenAIModel.java +++ b/src/main/java/io/github/stefanbratanov/jvm/openai/OpenAIModel.java @@ -14,7 +14,7 @@ */ public enum OpenAIModel { - // GPT-4 and GPT-4 Turbo (https://platform.openai.com/docs/models/gpt-3-5-turbo) + // GPT-4 and GPT-4 Turbo (https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) GPT_4("gpt-4"), GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview"), GPT_4_VISION_PREVIEW("gpt-4-vision-preview"), @@ -45,11 +45,11 @@ public enum OpenAIModel { private final String id; - OpenAIModel(String modelId) { - this.id = modelId; + OpenAIModel(String id) { + this.id = id; } public String getId() { - return this.id; + return id; } } diff --git a/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIAssistantsApiIntegrationTest.java b/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIAssistantsApiIntegrationTest.java index 043d90b..66c7cd0 100644 --- a/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIAssistantsApiIntegrationTest.java +++ b/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIAssistantsApiIntegrationTest.java @@ -10,7 +10,9 @@ import java.util.Optional; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; +@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".*\\S.*") class OpenAIAssistantsApiIntegrationTest extends OpenAIIntegrationTestBase { private static final Map METADATA = Map.of("modified", "true", "user", "abc123"); diff --git a/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIIntegrationTest.java b/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIIntegrationTest.java index 30c03ed..e954d80 100644 --- a/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIIntegrationTest.java +++ b/src/test/java/io/github/stefanbratanov/jvm/openai/OpenAIIntegrationTest.java @@ -16,10 +16,12 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.junit.jupiter.api.io.TempDir; import org.mockserver.integration.ClientAndServer; import org.mockserver.model.*; +@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".*\\S.*") class OpenAIIntegrationTest extends OpenAIIntegrationTestBase { @Test