tests/testthat/test-create.R

library(testthat)
library(ollamar)

test_that("create function works with basic input", {
    skip_if_not(test_connection(logical = TRUE), "Ollama server not available")

    expect_error(create("mario"))
    expect_error(create("mario", modelfile = "abc", path = "abc"))
    expect_error(create("mario", path = "abc"))

    resp <- create("mario", "FROM llama3\nSYSTEM You are mario from Super Mario Bros.")
    expect_s3_class(resp, "httr2_response")
    expect_equal(resp$status_code, 200)
    expect_true(model_avail("mario"))

    delete("mario")
    expect_false(model_avail("mario"))
})

Try the ollamar package in your browser

Any scripts or data that you put into this service are public.

ollamar documentation built on April 3, 2025, 8:31 p.m.