<commit_before>package store_test

import (
	"bytes"
	"github.com/bradylove/mescal/msg"
	"github.com/bradylove/mescal/store"
	"testing"
)

const (
	succeed = "\033[0;32m\u2713\033[0m"
	failed  = "\033[0;31m\u2717\033[0m"
)

func TestHandleCommandWithGetCommand(t *testing.T) {
	t.Log("Given I have a get command")
	{
		var b []byte
		buf := bytes.NewBuffer(b)
		sr := store.NewStore()
		cmd := msg.NewCommand("12345", msg.NewGetCommand("foo"))
		sr.HandleCommand(cmd, buf)
		sr.Close()
		sr.Wait()

		if len(buf.Bytes()) > 40 {
			t.Logf("It should have bytes %s", succeed)
		} else {
			t.Fatalf("It should have bytes %s", failed)
		}
	}
}

//func TestHandleCommandWithSetCommand(t *testing.T) {
//	t.Log("Given I have a set command")
//	{
//	}
//}<commit_msg>Adding a test for the set command<commit_after>package store_test

import (
	"bytes"
	"github.com/bradylove/mescal/msg"
	"github.com/bradylove/mescal/store"
	"testing"
)

const (
	succeed = "\033[0;32m\u2713\033[0m"
	failed  = "\033[0;31m\u2717\033[0m"
)

func TestHandleCommandWithGetCommand(t *testing.T) {
	t.Log("Given I have a get command")
	{
		var b []byte
		buf := bytes.NewBuffer(b)
		sr := store.NewStore()
		cmd := msg.NewCommand("12345", msg.NewGetCommand("foo"))
		sr.HandleCommand(cmd, buf)
		sr.Close()
		sr.Wait()

		if len(buf.Bytes()) > 40 {
			t.Logf("It should have bytes %s", succeed)
		} else {
			t.Fatalf("It should have bytes %s", failed)
		}
	}
}

func TestHandleCommandWithSetCommand(t *testing.T) {
	t.Log("Given I have a set command")
	{
		var b []byte
		buf := bytes.NewBuffer(b)
		sr := store.NewStore()
		cmd := msg.NewCommand("6790", msg.NewSetCommand("bar", "baz", 10000))
		sr.HandleCommand(cmd, buf)
		sr.Close()
		sr.Wait()

		if len(buf.Bytes()) > 40 {
			t.Logf("It should have bytes %s", succeed)
		} else {
			t.Fatalf("It should have bytes %s", failed)
		}
	}
}
{'fraction_non_alphanumeric': 0.17435622317596566, 'fraction_numerical': 0.04345493562231759, 'mean_word_length': 3.6625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3176105', 'n_tokens_mistral': 849, 'n_tokens_neox': 752, 'n_words': 158}