<commit_before>package hoverfly

import (
	"testing"
)

func TestSetMetadataKey(t *testing.T) {

	metaBucket := GetRandomName(10)
	md := NewBoltDBMetadata(TestDB, metaBucket)

	md.Set("foo", "bar")
	val, err := md.Get("foo")
	expect(t, err, nil)
	expect(t, val, "bar")
}

func TestDeleteMetadataKey(t *testing.T) {
	metaBucket := GetRandomName(10)
	md := NewBoltDBMetadata(TestDB, metaBucket)

	md.Set("foo", "bar")
	md.Delete("foo")

	_, err := md.Get("foo")
	refute(t, err, nil)
}

func TestGetAllValues(t *testing.T) {
	metaBucket := GetRandomName(10)
	md := NewBoltDBMetadata(TestDB, metaBucket)

	md.Set("foo", "bar")
	md.Set("foo2", "bar2")
	md.Set("foo3", "bar3")

	values, err := md.GetAll()
	expect(t, err, nil)
	expect(t, len(values), 3)
	expect(t, values["foo"], "bar")
}

func TestDeleteAllData(t *testing.T) {
	metaBucket := GetRandomName(10)
	md := NewBoltDBMetadata(TestDB, metaBucket)

	md.Set("foo", "bar")
	md.Set("foo2", "bar2")
	md.Set("foo3", "bar3")

	md.DeleteData()

	values, err := md.GetAll()
	expect(t, err, nil)
	expect(t, len(values), 0)
}<commit_msg>updating tests to use cache interface<commit_after>package hoverfly

import (
	"github.com/SpectoLabs/hoverfly/backends/boltdb"
	"testing"
)

func TestSetMetadataKey(t *testing.T) {

	metaBucket := GetRandomName(10)
	c := boltdb.NewBoltDBCache(TestDB, metaBucket)
	md := NewBoltDBMetadata(c)

	md.Set("foo", "bar")
	val, err := md.Get("foo")
	expect(t, err, nil)
	expect(t, val, "bar")
}

func TestDeleteMetadataKey(t *testing.T) {
	metaBucket := GetRandomName(10)
	c := boltdb.NewBoltDBCache(TestDB, metaBucket)
	md := NewBoltDBMetadata(c)

	md.Set("foo", "bar")
	md.Delete("foo")

	_, err := md.Get("foo")
	expect(t, err, nil)
}

func TestGetAllValues(t *testing.T) {
	metaBucket := GetRandomName(10)
	c := boltdb.NewBoltDBCache(TestDB, metaBucket)
	md := NewBoltDBMetadata(c)

	md.Set("foo", "bar")
	md.Set("foo2", "bar2")
	md.Set("foo3", "bar3")

	values, err := md.GetAll()
	expect(t, err, nil)
	expect(t, len(values), 3)
	expect(t, values["foo"], "bar")
}

func TestDeleteAllData(t *testing.T) {
	metaBucket := GetRandomName(10)
	c := boltdb.NewBoltDBCache(TestDB, metaBucket)
	md := NewBoltDBMetadata(c)

	md.Set("foo", "bar")
	md.Set("foo2", "bar2")
	md.Set("foo3", "bar3")

	md.DeleteData()

	values, err := md.GetAll()
	expect(t, err, nil)
	expect(t, len(values), 0)
}
{'fraction_non_alphanumeric': 0.1904156064461408, 'fraction_numerical': 0.015267175572519083, 'mean_word_length': 5.191601049868766, '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': '2527758', 'n_tokens_mistral': 1009, 'n_tokens_neox': 995, 'n_words': 192}