123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package model_entities
- import (
- "testing"
- "github.com/langgenius/dify-plugin-daemon/internal/utils/parser"
- )
- func TestRerankFullFunction(t *testing.T) {
- const (
- rerank = `
- {
- "model": "rerank",
- "docs": [
- {
- "index": 1,
- "text": "text",
- "score": 0.1
- }
- ]
- }`
- )
- _, err := parser.UnmarshalJsonBytes[RerankResult]([]byte(rerank))
- if err != nil {
- t.Error(err)
- }
- }
- func TestRerankWrongDocs(t *testing.T) {
- const (
- rerank = `
- {
- "model": "rerank",
- "docs": [
- {
- "index": 1,
- "text": "text"
- }
- ]
- }`
- )
- _, err := parser.UnmarshalJsonBytes[RerankResult]([]byte(rerank))
- if err == nil {
- t.Error("should have error")
- }
- }
- func TestRerankWrongDocIndex(t *testing.T) {
- const (
- rerank = `
- {
- "model": "rerank",
- "docs": [
- {
- "text": "text",
- "score": 0.1
- }
- ]
- }`
- )
- _, err := parser.UnmarshalJsonBytes[RerankResult]([]byte(rerank))
- if err == nil {
- t.Error("should have error")
- }
- }
|