Merge pull request #6146 from ollama/mxyng/testing

use testing tempdirs
This commit is contained in:
Michael Yang 2024-08-05 13:00:05 -07:00 committed by GitHub
commit 03bdac0595
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ package server
import (
"bytes"
"cmp"
"encoding/json"
"fmt"
"io"
@ -53,6 +54,8 @@ func (t *responseRecorder) CloseNotify() <-chan bool {
func createRequest(t *testing.T, fn func(*gin.Context), body any) *httptest.ResponseRecorder {
t.Helper()
// if OLLAMA_MODELS is not set, set it to the temp directory
t.Setenv("OLLAMA_MODELS", cmp.Or(os.Getenv("OLLAMA_MODELS"), t.TempDir()))
w := NewRecorder()
c, _ := gin.CreateTestContext(w)