<commit_before>package engine

import "testing"

type idtest struct {
	assertion string
	valid     bool
}

var idtests = []idtest{
	{"t_alice", true},
	{"t_bob", true},
	{"t_charlie", true},
	{"t_doug", true},
	{"t_ellen", false},
	{"t_ellen", false},
	{"<EMAIL>", false},
	{"t_alice+<EMAIL>aco@twitter", true},
	{"t_alice+tac<EMAIL>@<EMAIL>+<EMAIL>", true},
	{"<EMAIL>+<EMAIL>", false},
	{"<EMAIL>", true},
	{"<EMAIL>@<EMAIL>", true},
	{"<EMAIL>", true},
	{"kb<EMAIL>@<EMAIL>+t_bob", true},
	{"<EMAIL>+tac<EMAIL>", true},
	{"t_<EMAIL>+tac<EMAIL>@<EMAIL>", true},
	{"t_charlie+t_alice", false},
	{"t_charlie+kbtester2@github", false},
}

func TestIdentify(t *testing.T) {
	tc := SetupEngineTest(t, "Identify")
	defer tc.Cleanup()

	for _, x := range idtests {
		ctx := &Context{IdentifyUI: &FakeIdentifyUI{}}
		eng := NewIdentify(NewIdentifyArg(x.assertion, false))
		err := RunEngine(eng, ctx)
		if x.valid && err != nil {
			t.Errorf("assertion %q failed unexpectedly: %s", x.assertion, err)
		}
		if !x.valid && err == nil {
			t.Errorf("assertion %q passed unexpectedly", x.assertion)
		}
	}
}

func TestIdentifyWithTracking(t *testing.T) {
	tc := SetupEngineTest(t, "Identify")
	defer tc.Cleanup()<commit_msg>more specific assertions for max's very old local DB<commit_after>package engine

import "testing"

type idtest struct {
	assertion string
	valid     bool
}

var idtests = []idtest{
	{"t_alice", true},
	{"t_bob", true},
	{"t_charlie", true},
	{"t_doug", true},
	{"t_ellen", false},
	{"t_ellen", false},
	{"<EMAIL>", false},
	{"t_alice+tacovontaco@twitter", true},
	{"t_alice+tacovontaco@twitter+<EMAIL>2@github", true},
	{"<EMAIL>@twitter+<EMAIL>@<EMAIL>", false},
	{"kbtester2@github+t_alice", true},
	{"kb<EMAIL>@github+t_bob", true},
	{"kbtester1@twitter+t_bob", true},
	{"t_charlie+tacovontaco@twitter", true},
	{"t_charlie+tacoplusplus@github", true},
	{"t_charlie+t_alice", false},
	{"t_charlie+kbtester2@github", false},
}

func TestIdentify(t *testing.T) {
	tc := SetupEngineTest(t, "Identify")
	defer tc.Cleanup()

	for _, x := range idtests {
		ctx := &Context{IdentifyUI: &FakeIdentifyUI{}}
		eng := NewIdentify(NewIdentifyArg(x.assertion, false))
		err := RunEngine(eng, ctx)
		if x.valid && err != nil {
			t.Errorf("assertion %q failed unexpectedly: %s", x.assertion, err)
		}
		if !x.valid && err == nil {
			t.Errorf("assertion %q passed unexpectedly", x.assertion)
		}
	}
}

func TestIdentifyWithTracking(t *testing.T) {
	tc := SetupEngineTest(t, "Identify")
	defer tc.Cleanup()
{'fraction_non_alphanumeric': 0.20087684336389, 'fraction_numerical': 0.0019928258270227183, 'mean_word_length': 5.536458333333333, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '6784126', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1020, 'n_words': 203}