<commit_before>package controllers

import (
	"testing"

	"github.com/flimzy/diff"
)

type mockMC struct {
	ModelController
	t string
}

func (mc *mockMC) Type() string {
	return mc.t
}

const testMType = "foo"

var testMC = &mockMC{t: testMType}

func TestRegisterModelController(t *testing.T) {
	t.Run("Success", func(t *testing.T) {
		RegisterModelController(testMC)
		if _, ok := modelControllers[testMType]; !ok {
			t.Errorf("modelControllers not updated")
		}
		for _, t := range modelControllerTypes {
			if t == testMType {
				return
			}
		}
		t.Errorf("modelControllerTypes not updated")
	})
	t.Run("Duplicate", func(t *testing.T) {
		r := func() (r interface{}) {
			defer func() {
				r = recover()
			}()
			RegisterModelController(testMC)
			return
		}()
		expected := "A controller for 'foo' is already registered"
		if d := diff.Interface(expected, r); d != "" {
			t.Errorf(d)
		}
	})
}

func TestRegisteredModelControllers(t *testing.T) {
	expected := []string{"foo"}
	result := RegisteredModelControllers()
	if d := diff.Interface(expected, result); d != "" {
		t.Error(d)
	}
}
<commit_msg>Update controllers tests for new diff library.<commit_after>package controllers

import (
	"testing"

	"github.com/flimzy/diff"
)

type mockMC struct {
	ModelController
	t string
}

func (mc *mockMC) Type() string {
	return mc.t
}

const testMType = "foo"

var testMC = &mockMC{t: testMType}

func TestRegisterModelController(t *testing.T) {
	t.Run("Success", func(t *testing.T) {
		RegisterModelController(testMC)
		if _, ok := modelControllers[testMType]; !ok {
			t.Errorf("modelControllers not updated")
		}
		for _, t := range modelControllerTypes {
			if t == testMType {
				return
			}
		}
		t.Errorf("modelControllerTypes not updated")
	})
	t.Run("Duplicate", func(t *testing.T) {
		r := func() (r interface{}) {
			defer func() {
				r = recover()
			}()
			RegisterModelController(testMC)
			return
		}()
		expected := "A controller for 'foo' is already registered"
		if d := diff.Interface(expected, r); d != nil {
			t.Error(d)
		}
	})
}

func TestRegisteredModelControllers(t *testing.T) {
	expected := []string{"foo"}
	result := RegisteredModelControllers()
	if d := diff.Interface(expected, result); d != nil {
		t.Error(d)
	}
}

{'fraction_non_alphanumeric': 0.14849290780141844, 'fraction_numerical': 0.0, 'mean_word_length': 3.8433476394849784, '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': '1983619', 'n_tokens_mistral': 864, 'n_tokens_neox': 798, 'n_words': 188}