lint: enable usetesting, disable tenv (#10594)

This commit is contained in:
Michael Yang 2025-05-08 11:42:14 -07:00 committed by GitHub
parent b585a58121
commit 6e9a7a2568
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 55 additions and 87 deletions

View file

@ -1,7 +1,6 @@
package server
import (
"os"
"path/filepath"
"testing"
@ -11,9 +10,7 @@ import (
func TestGetBlobsPath(t *testing.T) {
// GetBlobsPath expects an actual directory to exist
dir, err := os.MkdirTemp("", "ollama-test")
require.NoError(t, err)
defer os.RemoveAll(dir)
tempDir := t.TempDir()
tests := []struct {
name string
@ -24,19 +21,19 @@ func TestGetBlobsPath(t *testing.T) {
{
"empty digest",
"",
filepath.Join(dir, "blobs"),
filepath.Join(tempDir, "blobs"),
nil,
},
{
"valid with colon",
"sha256:456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9",
filepath.Join(dir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
filepath.Join(tempDir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
nil,
},
{
"valid with dash",
"sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9",
filepath.Join(dir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
filepath.Join(tempDir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
nil,
},
{
@ -60,7 +57,7 @@ func TestGetBlobsPath(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("OLLAMA_MODELS", dir)
t.Setenv("OLLAMA_MODELS", tempDir)
got, err := GetBlobsPath(tc.digest)