<commit_before>package coal

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"go.mongodb.org/mongo-driver/bson"
)

func TestIndexerEnsure(t *testing.T) {
	tester.Clean()

	indexer := NewIndexer()
	indexer.Add(&postModel{}, false, 0, "Title")
	indexer.AddPartial(&commentModel{}, false, 0, []string{"Post"}, bson.M{
		F(&commentModel{}, "Message"): "test",
	})

	err := indexer.Ensure(tester.Store)
	assert.NoError(t, err)
}

func TestIndexerEnsureError(t *testing.T) {
	tester.Clean()

	indexer := NewIndexer()
	indexer.Add(&postModel{}, true, 0, "Published")
	assert.NoError(t, indexer.Ensure(tester.Store))

	indexer = NewIndexer()
	indexer.Add(&postModel{}, false, 0, "Published")
	assert.Error(t, indexer.Ensure(tester.Store))
}<commit_msg>do not add unique index<commit_after>package coal

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"go.mongodb.org/mongo-driver/bson"
)

func TestIndexerEnsure(t *testing.T) {
	tester.Clean()

	indexer := NewIndexer()
	indexer.Add(&postModel{}, false, 0, "Title")
	indexer.AddPartial(&commentModel{}, false, 0, []string{"Post"}, bson.M{
		F(&commentModel{}, "Message"): "test",
	})

	err := indexer.Ensure(tester.Store)
	assert.NoError(t, err)
}

func TestIndexerEnsureError(t *testing.T) {
	tester.Clean()

	indexer := NewIndexer()
	indexer.Add(&postModel{}, false, 0, "Published")
	assert.NoError(t, indexer.Ensure(tester.Store))

	indexer = NewIndexer()
	indexer.Add(&postModel{}, true, 0, "Published")
	assert.Error(t, indexer.Ensure(tester.Store))
}
{'fraction_non_alphanumeric': 0.18265440210249673, 'fraction_numerical': 0.005256241787122208, 'mean_word_length': 5.650655021834061, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3583270', 'n_tokens_mistral': 609, 'n_tokens_neox': 595, 'n_words': 100}