Skip to content

Commit 1e6eab5

Browse files
authored
server: use slices.Equal to simplify code (ollama#11502)
1 parent 6c733bf commit 1e6eab5

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

server/routes_test.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"path/filepath"
1818
"reflect"
19+
"slices"
1920
"sort"
2021
"strings"
2122
"testing"
@@ -82,19 +83,6 @@ func createTestFile(t *testing.T, name string) (string, string) {
8283
return f.Name(), digest
8384
}
8485

85-
// equalStringSlices checks if two slices of strings are equal.
86-
func equalStringSlices(a, b []string) bool {
87-
if len(a) != len(b) {
88-
return false
89-
}
90-
for i := range a {
91-
if a[i] != b[i] {
92-
return false
93-
}
94-
}
95-
return true
96-
}
97-
9886
type panicTransport struct{}
9987

10088
func (t *panicTransport) RoundTrip(r *http.Request) (*http.Response, error) {
@@ -447,7 +435,7 @@ func TestRoutes(t *testing.T) {
447435
"stop \"foo\"",
448436
"top_p 0.9",
449437
}
450-
if !equalStringSlices(params, expectedParams) {
438+
if !slices.Equal(params, expectedParams) {
451439
t.Errorf("expected parameters %v, got %v", expectedParams, params)
452440
}
453441
paramCount, ok := showResp.ModelInfo["general.parameter_count"].(float64)

0 commit comments

Comments
 (0)