mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-04 06:40:29 +08:00
refactor: use slices.Contains to simplify code (#16680)
### Summary There is a [new function](https://pkg.go.dev/slices@go1.21.0#Contains) added in the go1.21 standard library, which can make the code more concise and easy to read. Signed-off-by: weifanglab <weifanglab@outlook.com>
This commit is contained in:
@@ -15,6 +15,7 @@ package component
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
@@ -178,14 +179,7 @@ func TestLLM_Invoke_InvokerError(t *testing.T) {
|
||||
|
||||
func TestLLM_Registered(t *testing.T) {
|
||||
names := RegisteredNames()
|
||||
found := false
|
||||
for _, n := range names {
|
||||
if n == "llm" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
if !slices.Contains(names, "llm") {
|
||||
t.Fatalf("LLM not registered; names=%v", names)
|
||||
}
|
||||
// And a factory round-trip.
|
||||
|
||||
@@ -35,6 +35,7 @@ package component
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -45,14 +46,7 @@ import (
|
||||
// assert their absence here.
|
||||
func TestParallel_Registered(t *testing.T) {
|
||||
names := RegisteredNames()
|
||||
hasParallel := false
|
||||
for _, n := range names {
|
||||
if n == "parallel" {
|
||||
hasParallel = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasParallel {
|
||||
if !slices.Contains(names, "parallel") {
|
||||
t.Errorf("Parallel not registered; RegisteredNames=%v", names)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user