<commit_before>package lmdbcli

import (
	"bytes"
	"testing"
	"time"

	. "github.com/karlseguin/expect"
)

type CLITests struct {
	context  *Context
	recorder *Recorder
}

func Test_CLI(t *testing.T) {
	Expectify(new(CLITests), t)
}

func (c *CLITests) Each(test func()) {
	c.context = NewTestContext()
	c.recorder = c.context.writer.(*Recorder)
	defer c.context.Close()
	test()
}

func (t CLITests) GetsAnExistingKey() {
	get(t.context, "over")
	t.recorder.assert("9000!!")
}

func (t CLITests) VerifyExistingKey() {
	exists(t.context, "over")
	t.recorder.assert("true")
}

func (t CLITests) VerifyMissingKey() {
	exists(t.context, "nowaythiskeyexists")
	t.recorder.assert("false")
}

func (t CLITests) DeletesAMissingKey() {
	t.withinShell("del nowaythiskeyexists")
	t.recorder.assert("MDB_NOTFOUND: No matching key/data pair found")
}

func (t CLITests) DeletesAKey() {
	del(t.context, "over")
	exists(t.context, "over")
	t.recorder.assert("ok", "false")
}

func (t CLITests) Exits() {
	for _, input := range []string{"exit", "quit"} {
		done := false
		in := bytes.NewBufferString(input + "\n")
		go func() {
			runShell(t.context, in)
			done = true
		}()<commit_msg>fixed all the broken tests<commit_after>package lmdbcli

import (
	"bytes"
	"testing"
	"time"

	. "github.com/karlseguin/expect"
)

type CLITests struct {
	context  *Context
	recorder *Recorder
}

func Test_CLI(t *testing.T) {
	Expectify(new(CLITests), t)
}

func (c *CLITests) Each(test func()) {
	c.context = NewTestContext()
	c.recorder = c.context.writer.(*Recorder)
	defer c.context.Close()
	test()
}

func (t CLITests) GetsAnExistingKey() {
	t.withinShell("get over")
	t.recorder.assert("9000!!")
}

func (t CLITests) VerifyExistingKey() {
	t.withinShell("exists over")
	t.recorder.assert("true")
}

func (t CLITests) VerifyMissingKey() {
	t.withinShell("exists nowaythiskeyexists")
	t.recorder.assert("false")
}

func (t CLITests) DeletesAMissingKey() {
	t.withinShell("del nowaythiskeyexists")
	t.recorder.assert("MDB_NOTFOUND: No matching key/data pair found")
}

func (t CLITests) DeletesAKey() {
	t.withinShell("del over", "exists over")
	t.recorder.assert("ok", "false")
}

func (t CLITests) Exits() {
	for _, input := range []string{"exit", "quit"} {
		done := false
		in := bytes.NewBufferString(input + "\n")
		go func() {
			runShell(t.context, in)
			done = true
		}()
{'fraction_non_alphanumeric': 0.16758591429783623, 'fraction_numerical': 0.0033941450997030122, 'mean_word_length': 4.709443099273607, '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': '4456567', 'n_tokens_mistral': 966, 'n_tokens_neox': 937, 'n_words': 192}