mirror of
https://github.com/ollama/ollama.git
synced 2025-08-26 19:11:39 +02:00
server: use slices.Equal to simplify code (#11502)
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -82,19 +83,6 @@ func createTestFile(t *testing.T, name string) (string, string) {
|
|||||||
return f.Name(), digest
|
return f.Name(), digest
|
||||||
}
|
}
|
||||||
|
|
||||||
// equalStringSlices checks if two slices of strings are equal.
|
|
||||||
func equalStringSlices(a, b []string) bool {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for i := range a {
|
|
||||||
if a[i] != b[i] {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type panicTransport struct{}
|
type panicTransport struct{}
|
||||||
|
|
||||||
func (t *panicTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
func (t *panicTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||||
@@ -447,7 +435,7 @@ func TestRoutes(t *testing.T) {
|
|||||||
"stop \"foo\"",
|
"stop \"foo\"",
|
||||||
"top_p 0.9",
|
"top_p 0.9",
|
||||||
}
|
}
|
||||||
if !equalStringSlices(params, expectedParams) {
|
if !slices.Equal(params, expectedParams) {
|
||||||
t.Errorf("expected parameters %v, got %v", expectedParams, params)
|
t.Errorf("expected parameters %v, got %v", expectedParams, params)
|
||||||
}
|
}
|
||||||
paramCount, ok := showResp.ModelInfo["general.parameter_count"].(float64)
|
paramCount, ok := showResp.ModelInfo["general.parameter_count"].(float64)
|
||||||
|
Reference in New Issue
Block a user