Skip to content

Commit

Permalink
Add test cases #19
Browse files Browse the repository at this point in the history
  • Loading branch information
hauselin committed Jul 29, 2024
1 parent 436fa6e commit e1468a5
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/ollama.R
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ embed <- function(model, input, truncate = TRUE, normalize = TRUE, keep_alive =



#' Get vector embedding for a single prompt
#' Get vector embedding for a single prompt - deprecated in favor of `embed()`
#'
#' This function will be deprecated over time and has been superceded by `embed()`. See `embed()` for more details.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ resp_process <- function(resp, output = c("df", "jsonlist", "raw", "resp", "text
return(NULL)
}

endpoints_to_skip <- c("api/delete")
endpoints_to_skip <- c("api/delete", "api/embed", "api/embeddings")
for (endpoint in endpoints_to_skip) {
if (grepl(endpoint, resp$url)) {
message("Returning response object because resp_process not supported for this endpoint.")
Expand Down
2 changes: 1 addition & 1 deletion man/embeddings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/testthat/test-copy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("copy function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})
6 changes: 6 additions & 0 deletions tests/testthat/test-create.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("create function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})
6 changes: 6 additions & 0 deletions tests/testthat/test-embed.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("embed function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})
6 changes: 6 additions & 0 deletions tests/testthat/test-embeddings.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("embeddings function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})
9 changes: 9 additions & 0 deletions tests/testthat/test-model_avail.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library(testthat)
library(ollamar)

test_that("model_avail function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")

expect_false(model_avail("test"))
expect_true(model_avail("llama3"))
})
6 changes: 6 additions & 0 deletions tests/testthat/test-ps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("ps function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})
6 changes: 6 additions & 0 deletions tests/testthat/test-push.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
library(testthat)
library(ollamar)

test_that("push function works with basic input", {
skip_if_not(test_connection()$status_code == 200, "Ollama server not available")
})

0 comments on commit e1468a5

Please sign in to comment.