Files

25 lines
543 B
Go

package embedding
import (
"context"
"testing"
)
func TestFakeProviderDeterministic(t *testing.T) {
p := NewFakeProvider(1536, "fake")
a, err := p.Embed(context.Background(), []string{"hello", "world"})
if err != nil {
t.Fatal(err)
}
b, _ := p.Embed(context.Background(), []string{"hello"})
if len(a) != 2 || len(a[0]) != 1536 || len(b[0]) != 1536 {
t.Fatalf("bad dims")
}
if a[0][0] != b[0][0] {
t.Fatalf("not deterministic")
}
if a[0][0] == a[1][0] && a[0][1] == a[1][1] {
t.Fatalf("different inputs too similar")
}
}