<commit_before>package quotidian.web.controller

import org.apache.lucene.index.IndexReader
import quotidian.DatastoreSpecification
import quotidian.model.Quote

object DatastoreQuoteControllerSpecs extends DatastoreSpecification {
	val controller = new DatastoreQuoteController
	"A controller" should {
		datastoreCleanup.before
		val quote = Quote("this is some text","this is a source","and this is context")
		"save a quote" >> {
			val key = controller.save(quote)
			key must notBeNull
		}
		"have a searcher with a reader with terms" >> {
			controller.save(quote)
			val terms = controller.searcher.getIndexReader.terms
			terms.next mustEqual true
		}
	}
}<commit_msg>Add new specs isolating Quote writing to Index<commit_after>package quotidian.web.controller

import org.apache.lucene.analysis.standard.StandardAnalyzer
import org.apache.lucene.index.{IndexReader,IndexWriter}
import org.apache.lucene.index.IndexWriter.MaxFieldLength.UNLIMITED
import org.apache.lucene.search.IndexSearcher
import quotidian.DatastoreSpecification
import quotidian.model.Quote
import quotidian.search.DatastoreDirectory

object DatastoreQuoteControllerSpecs extends DatastoreSpecification {
	val controller = new DatastoreQuoteController
	"A DatastoreDirectory" should {
		datastoreCleanup.before
		"be able to have Quotes written to it" >> {
			val quote = Quote("this is some text","this is a source","and this is context")
			val directory = new DatastoreDirectory()
			val writer = new IndexWriter(directory,new StandardAnalyzer(),UNLIMITED)
			writer.addDocument(quote)
			writer.commit
			val searcher = new IndexSearcher(directory)
			val reader = searcher.getIndexReader
			val terms = reader.terms
			terms.next mustEqual true
			reader.close
		}
	}
	"A controller" should {
		datastoreCleanup.before
		val quote = Quote("this is some text","this is a source","and this is context")
		"save a quote" >> {
			val key = controller.save(quote)
			key must notBeNull
		}
		"have a searcher with a reader with terms" >> {
			controller.save(quote)
			val reader = controller.searcher.getIndexReader
			val terms = reader.terms
			terms.next mustEqual true
			reader.close
		}
	}
}
{'fraction_non_alphanumeric': 0.081267217630854, 'fraction_numerical': 0.0, 'mean_word_length': 4.674479166666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2656064', 'n_tokens_mistral': 724, 'n_tokens_neox': 646, 'n_words': 180}