<commit_before>package format

import (
	"testing"

	"github.com/trivago/gollum/core"
	"github.com/trivago/tgo/ttesting"
)

func TestSplitPick_Success(t *testing.T) {
	expect := ttesting.NewExpect(t)

	config := core.NewPluginConfig("", "format.SplitPick")
	config.Settings["SplitPickIndex"] = 0
	config.Settings["SplitPickDelimiter"] = "#"
	plugin, err := core.NewPlugin(config)

	expect.NoError(err)

	formatter, casted := plugin.(*SplitPick)
	expect.True(casted)

	msg := core.NewMessage(nil, []byte("MTIzNDU2#NjU0MzIx"), 0, core.InvalidStreamID)
	result := formatter.Modulate(msg)

	expect.Equal(core.ModulateResultContinue, result)
	expect.Equal("MTIzNDU2", msg.String())

}

func TestSplitPick_OutOfBoundIndex(t *testing.T) {
	expect := ttesting.NewExpect(t)

	config := core.NewPluginConfig("", "format.SplitPick")
	config.Settings["SplitPickIndex"] = 2
	plugin, err := core.NewPlugin(config)

	expect.NoError(err)

	formatter, casted := plugin.(*SplitPick)
	expect.True(casted)<commit_msg>Made format/splitpick_test compatible with v0.5.0<commit_after>package format

import (
	"testing"

	"github.com/trivago/gollum/core"
	"github.com/trivago/tgo/ttesting"
)

func TestSplitPick_Success(t *testing.T) {
	expect := ttesting.NewExpect(t)

	config := core.NewPluginConfig("", "format.SplitPick")
	config.Override("SplitPickIndex", 0)
	config.Override("SplitPickDelimiter", "#")
	plugin, err := core.NewPlugin(config)

	expect.NoError(err)

	formatter, casted := plugin.(*SplitPick)
	expect.True(casted)

	msg := core.NewMessage(nil, []byte("MTIzNDU2#NjU0MzIx"), 0, core.InvalidStreamID)
	result := formatter.Modulate(msg)

	expect.Equal(core.ModulateResultContinue, result)
	expect.Equal("MTIzNDU2", msg.String())

}

func TestSplitPick_OutOfBoundIndex(t *testing.T) {
	expect := ttesting.NewExpect(t)

	config := core.NewPluginConfig("", "format.SplitPick")
	config.Override("SplitPickIndex", 2)
	plugin, err := core.NewPlugin(config)

	expect.NoError(err)

	formatter, casted := plugin.(*SplitPick)
	expect.True(casted)
{'fraction_non_alphanumeric': 0.15540207202762704, 'fraction_numerical': 0.00740009866798224, 'mean_word_length': 6.066202090592334, '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': '7452820', 'n_tokens_mistral': 783, 'n_tokens_neox': 732, 'n_words': 111}