<commit_before>package rtm

import (
	"testing"

	"github.com/firba1/slack"

	"github.com/firba1/util/assert"
)

func TestUnescapeMessage(t *testing.T) {
	tests := []struct {
		in  string
		out string
	}{
		// HTML entity replacements
		{"Simon &amp; Garfunkel", "Simon & Garfunkel"},
		{"Independence Day &gt; Stargate", "Independence Day > Stargate"},
		{"):&lt;", "):<"},
		// existing user
		{"<@U123A56BC>++", "@fart++"},
		// user with an alias
		{"<@U123A56BC|butt>++", "@butt++"},
		// unrecognized user
		{"<@UXYZ987WV>++", "<@UXYZ987WV>++"},
	}

	conn := Conn{cancel: make(chan struct{})}
	users := []slack.User{
		slack.User{
			ID:   "U123A56BC",
			Name: "fart",
		},
	}
	conn.userChanges, conn.infoRequests = serveUserInfo(users, conn.cancel)

	for _, test := range tests {<commit_msg>Refactored TestUnescapeMessage to be better.<commit_after>package rtm

import (
	"testing"

	"github.com/firba1/slack"

	"github.com/firba1/util/assert"
	"github.com/gorilla/websocket"
)

func TestUnescapeMessage(t *testing.T) {
	tests := []struct {
		in  string
		out string
	}{
		// HTML entity replacements
		{"Simon &amp; Garfunkel", "Simon & Garfunkel"},
		{"Independence Day &gt; Stargate", "Independence Day > Stargate"},
		{"):&lt;", "):<"},
		// existing user
		{"<@U123A56BC>++", "@fart++"},
		// user with an alias
		{"<@U123A56BC|butt>++", "@butt++"},
		// unrecognized user
		{"<@UXYZ987WV>++", "<@UXYZ987WV>++"},
	}

	conn, err := Dialer{
		rtmStartFunc: func(token string) (*websocket.Conn, slack.RTMStartInfo, error) {
			rtmStartInfo := slack.RTMStartInfo{
				Users: []slack.User{
					slack.User{
						ID:   "U123A56BC",
						Name: "fart",
					},
				},
			}
			return nil, rtmStartInfo, nil
		},
	}.Dial("")
	assert.NilError(t, err)

	for _, test := range tests {
{'fraction_non_alphanumeric': 0.2, 'fraction_numerical': 0.0257703081232493, 'mean_word_length': 3.7374005305039786, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2922213', 'n_tokens_mistral': 829, 'n_tokens_neox': 706, 'n_words': 143}