// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef

// E2e tests for category: embed_async_pending
package e2e_test

import (
	"encoding/json"
	"testing"

	"github.com/stretchr/testify/assert"

	kreuzberg "github.com/kreuzberg-dev/kreuzberg/v5"
)

func Test_EmbedTextsAsyncEmptyInput(t *testing.T) {
	// embed_texts_async: empty text list
	var texts []string
	if err := json.Unmarshal([]byte(`[]`), &texts); err != nil {
		t.Fatalf("config parse failed: %v", err)
	}
	result, err := kreuzberg.EmbedTextsAsync(texts, kreuzberg.EmbeddingConfig{})
	if err != nil {
		t.Fatalf("call failed: %v", err)
	}
	value := result
	assert.Equal(t, len(value), 0, "expected exactly 0 elements")
}

func Test_EmbedTextsAsyncHappy(t *testing.T) {
	// embed_texts_async: basic async embedding
	var texts []string
	if err := json.Unmarshal([]byte(`["first","second"]`), &texts); err != nil {
		t.Fatalf("config parse failed: %v", err)
	}
	result, err := kreuzberg.EmbedTextsAsync(texts, kreuzberg.EmbeddingConfig{})
	if err != nil {
		t.Fatalf("call failed: %v", err)
	}
	value := result
	assert.GreaterOrEqual(t, len(value), 2, "expected at least 2 elements")
}

func Test_EmbedTextsAsyncPresetSwitch(t *testing.T) {
	// embed_texts_async: preset override
	var texts []string
	if err := json.Unmarshal([]byte(`["text"]`), &texts); err != nil {
		t.Fatalf("config parse failed: %v", err)
	}
	var config kreuzberg.EmbeddingConfig
	if err := json.Unmarshal([]byte(`{"model":{"name":"balanced","type":"preset"}}`), &config); err != nil {
		t.Fatalf("config parse failed: %v", err)
	}
	_, err := kreuzberg.EmbedTextsAsync(texts, config)
	if err != nil {
		t.Fatalf("call failed: %v", err)
	}
}
