[PR #2177] [CLOSED] added example tests to document client and improve coverage #10809

Closed
opened 2026-04-12 23:11:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2177
Author: @TimothyStiles
Created: 1/24/2024
Status: Closed

Base: mainHead: client-example-tests


📝 Commits (10+)

  • 4bdb53c added example test usage to document client and improve coverage.
  • 799ba11 added unit test for client's create method along with minimal viable gguf file for unit testing.
  • f98f113 removed Heartbeat, Show, and Version client methods from Example_basic.
  • 2d2b212 added tiny test files to use in examples for creating models from file.
  • edd08f6 removed example_basic as it was a duplicate of ExampleClient_Chat
  • a227e08 cleaned up a couple of comments.
  • cb4879c moved ExampleClient_Show
  • 5f39d4c TestMain now creates a tiny spoof model if none are detected in the local env and deletes it on completion.
  • 87a88cc removed tiny unviable .guff file and added a viable tiny model for testing.
  • 8ce63ea cleaning up comments.

📊 Changes

4 files changed (+407 additions, -0 deletions)

View changed files

api/data/README.md (+7 -0)
api/data/llama-2-tiny-random.gguf (+0 -0)
api/data/llama-2-tiny-random.model (+5 -0)
api/example_test.go (+395 -0)

📄 Description

Hey y'all,

Pleasure meeting @jmorganca and some of you at last night's event!

This PR fixes #2159 by adding example tests to the client api package that will also render in the go docs. These examples show how to check server heartbeat, get server version, list out available models, sort those models by size, and then chat with the smallest model found.

Things to note:

  1. This PR increases line coverage in the api package from 8.2% to 55.6%.
  2. No new features or breaking changes.
  3. No changes to currently existing code.
  4. These tests will auto-render as examples on pkg.go.dev, and provide stable and easy to maintain documentation.
  5. I've included a tiny llama model in a new api/data directory along with a README. It's 1.8mb and its responses are mostly gibberish but work great for unit testing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/2177 **Author:** [@TimothyStiles](https://github.com/TimothyStiles) **Created:** 1/24/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `client-example-tests` --- ### 📝 Commits (10+) - [`4bdb53c`](https://github.com/ollama/ollama/commit/4bdb53cd2caf06a45c2b4ff3eaaffa305f3394d6) added example test usage to document client and improve coverage. - [`799ba11`](https://github.com/ollama/ollama/commit/799ba11edc7a637308678b8b27353b9b1fb70ff7) added unit test for client's create method along with minimal viable gguf file for unit testing. - [`f98f113`](https://github.com/ollama/ollama/commit/f98f113b756ee475aa8e37dd79765da5db2c868a) removed Heartbeat, Show, and Version client methods from Example_basic. - [`2d2b212`](https://github.com/ollama/ollama/commit/2d2b212e3d009a49f697a08ece5314bc5090fd7e) added tiny test files to use in examples for creating models from file. - [`edd08f6`](https://github.com/ollama/ollama/commit/edd08f62ab6c3a8f6dda4205839df0f76511df89) removed example_basic as it was a duplicate of ExampleClient_Chat - [`a227e08`](https://github.com/ollama/ollama/commit/a227e087344eca7151dd26fc888853289789b66b) cleaned up a couple of comments. - [`cb4879c`](https://github.com/ollama/ollama/commit/cb4879c337030f642e298528f8a332224c7f3745) moved ExampleClient_Show - [`5f39d4c`](https://github.com/ollama/ollama/commit/5f39d4cdff23cebaf403deccb200e2a1c674fd29) TestMain now creates a tiny spoof model if none are detected in the local env and deletes it on completion. - [`87a88cc`](https://github.com/ollama/ollama/commit/87a88cc8f923eb0d8b65c45a4b31cd87b34ee5b1) removed tiny unviable .guff file and added a viable tiny model for testing. - [`8ce63ea`](https://github.com/ollama/ollama/commit/8ce63ea9e6e3144896c31e9632b11892bc5e131f) cleaning up comments. ### 📊 Changes **4 files changed** (+407 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `api/data/README.md` (+7 -0) ➕ `api/data/llama-2-tiny-random.gguf` (+0 -0) ➕ `api/data/llama-2-tiny-random.model` (+5 -0) ➕ `api/example_test.go` (+395 -0) </details> ### 📄 Description Hey y'all, Pleasure meeting @jmorganca and some of you at last night's event! This PR fixes #2159 by adding example tests to the client `api` package that will also render in the go docs. These examples show how to check server heartbeat, get server version, list out available models, sort those models by size, and then chat with the smallest model found. Things to note: 1. This PR increases line coverage in the `api` package from 8.2% to **55.6%**. 2. No new features or breaking changes. 3. No changes to currently existing code. 4. These tests will auto-render as examples on [pkg.go.dev](https://pkg.go.dev/github.com/jmorganca/ollama), and provide stable and easy to maintain documentation. 5. I've included a tiny llama model in a new `api/data` directory along with a `README`. It's 1.8mb and its responses are mostly gibberish but work great for unit testing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-12 23:11:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#10809