<commit_before>package errors

import (
	"testing"

	"github.com/jochasinga/grx/utils/unittest"
	"github.com/stretchr/testify/assert"
)

func TestErrorCodes(t *testing.T) {
	errors := []Code{
		EndOfIteratorError,
		NilObservableError,
		NilEventStreamError,
		NilObserverError,
		UndefinedError,
	}
	errorEnumTests := unittest.Tables{}

	for i, err := range errors {
		errorEnumTests = append(errorEnumTests, unittest.Table{err, i})
	}

	assert := assert.New(t)

	for _, tt := range errorEnumTests {
		assert.EqualValues(tt.Expected, tt.Actual)
	}
}

func TestBaseErrorWithDefaultMessage(t *testing.T) {
	baseError := New(EndOfIteratorError)
	baseErrorTests := unittest.Tables{
		{baseError.code, Code(0)},
		{baseError.message, "EndOfIteratorError"},
	}

	assert := assert.New(t)
	for _, tt := range baseErrorTests {
		assert.Equal(tt.Expected, tt.Actual)
	}
}

func TestBaseErrorWithCustomMessage(t *testing.T) {
	baseError := New(NilObservableError, "Observable is set to nil")
	baseErrorTests := unittest.Tables{
		{baseError.code, Code(1)},
		{baseError.message, "Observable is set to nil"},
	}

	assert := assert.New(t)
	for _, tt := range baseErrorTests {
		assert.Equal(tt.Expected, tt.Actual)
	}
}<commit_msg>tests passed<commit_after>package errors

import (
	"testing"

	"github.com/jochasinga/grx/utils/unittest"
	"github.com/stretchr/testify/assert"
)

func TestErrorCodes(t *testing.T) {
	errors := []Code{
		EndOfIteratorError,
		NilObservableError,
		NilEventStreamError,
		NilObserverError,
		UndefinedError,
	}
	errorEnumTests := unittest.Tables{}

	for i, err := range errors {
		errorEnumTests = append(errorEnumTests, unittest.Table{err, i})
	}

	assert := assert.New(t)

	for _, tt := range errorEnumTests {
		assert.EqualValues(tt.Expected, tt.Actual)
	}
}

func TestBaseErrorWithDefaultMessage(t *testing.T) {
	baseError := New(EndOfIteratorError)
	baseErrorTests := unittest.Tables{
		{baseError.code, Code(0)},
		{baseError.message, "EndOfIteratorError"},
	}

	assert := assert.New(t)
	for _, tt := range baseErrorTests {
		assert.Equal(tt.Expected, tt.Actual)
	}
}

func TestBaseErrorWithCustomMessage(t *testing.T) {
	baseError := New(NilObservableError, "Observable is set to nil")
	baseErrorTests := unittest.Tables{
		{baseError.code, Code(1)},
		{baseError.message, "Observable is set to nil"},
	}

	assert := assert.New(t)
	for _, tt := range baseErrorTests {
		assert.Equal(tt.Expected, tt.Actual)
	}
}

func TestErrorMethod(t *testing.T) {
	baseError := New(UndefinedError)
	assert.Equal(t, "4 - UndefinedError", baseError.Error())
}

func TestCodeMethod(t *testing.T) {
	baseError := New(UndefinedError)
	assert.EqualValues(t, 4, baseError.Code())
}
{'fraction_non_alphanumeric': 0.1366344005956813, 'fraction_numerical': 0.0022338049143708115, 'mean_word_length': 4.905494505494506, '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': '1164272', 'n_tokens_mistral': 991, 'n_tokens_neox': 954, 'n_words': 182}