mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 20:07:10 +02:00
Fixes to tests
This commit is contained in:
parent
4e4a5d2996
commit
d52427fb68
@ -1,19 +1,18 @@
|
|||||||
package io.github.amithkoujalgi.ollama4j;
|
package io.github.amithkoujalgi.ollama4j;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import io.github.amithkoujalgi.ollama4j.core.OllamaAPI;
|
import io.github.amithkoujalgi.ollama4j.core.OllamaAPI;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.exceptions.OllamaBaseException;
|
import io.github.amithkoujalgi.ollama4j.core.exceptions.OllamaBaseException;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.models.ModelDetail;
|
import io.github.amithkoujalgi.ollama4j.core.models.ModelDetail;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.models.OllamaAsyncResultCallback;
|
import io.github.amithkoujalgi.ollama4j.core.models.OllamaAsyncResultCallback;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.models.OllamaResult;
|
import io.github.amithkoujalgi.ollama4j.core.models.OllamaResult;
|
||||||
import io.github.amithkoujalgi.ollama4j.core.types.OllamaModelType;
|
import io.github.amithkoujalgi.ollama4j.core.types.OllamaModelType;
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.mockito.Mockito.*;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
public class TestMockedAPIs {
|
public class TestMockedAPIs {
|
||||||
@Test
|
@Test
|
||||||
@ -101,7 +100,7 @@ public class TestMockedAPIs {
|
|||||||
String model = OllamaModelType.LLAMA2;
|
String model = OllamaModelType.LLAMA2;
|
||||||
String prompt = "some prompt text";
|
String prompt = "some prompt text";
|
||||||
try {
|
try {
|
||||||
when(ollamaAPI.ask(model, prompt)).thenReturn(new OllamaResult("", 0));
|
when(ollamaAPI.ask(model, prompt)).thenReturn(new OllamaResult("", 0, 200));
|
||||||
ollamaAPI.ask(model, prompt);
|
ollamaAPI.ask(model, prompt);
|
||||||
verify(ollamaAPI, times(1)).ask(model, prompt);
|
verify(ollamaAPI, times(1)).ask(model, prompt);
|
||||||
} catch (IOException | OllamaBaseException | InterruptedException e) {
|
} catch (IOException | OllamaBaseException | InterruptedException e) {
|
||||||
@ -114,7 +113,8 @@ public class TestMockedAPIs {
|
|||||||
OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class);
|
OllamaAPI ollamaAPI = Mockito.mock(OllamaAPI.class);
|
||||||
String model = OllamaModelType.LLAMA2;
|
String model = OllamaModelType.LLAMA2;
|
||||||
String prompt = "some prompt text";
|
String prompt = "some prompt text";
|
||||||
when(ollamaAPI.askAsync(model, prompt)).thenReturn(new OllamaAsyncResultCallback(null, null, null));
|
when(ollamaAPI.askAsync(model, prompt))
|
||||||
|
.thenReturn(new OllamaAsyncResultCallback(null, null, null));
|
||||||
ollamaAPI.askAsync(model, prompt);
|
ollamaAPI.askAsync(model, prompt);
|
||||||
verify(ollamaAPI, times(1)).askAsync(model, prompt);
|
verify(ollamaAPI, times(1)).askAsync(model, prompt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user