<commit_before>package mails

import (
	"fmt"
	"testing"

	"github.com/toomore/mailbox/campaign"
	"github.com/toomore/mailbox/utils"
)

func TestGenParams(t *testing.T) {
	t.Logf("%+v", GenParams("<EMAIL>", "message", "[Test]"))
}

func TestProcessSend(t *testing.T) {
	stmt, err := utils.GetConn().Prepare(`INSERT INTO user(email,groups,f_name,l_name)
	                           VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE f_name=?, l_name=?`)
	if err != nil {
		t.Fatal(err)
	}
	stmt.Exec("<EMAIL>", "test", "Toomore", "Chiang", "Toomore", "Chiang")
	rows, err := utils.GetConn().Query("select id,email,f_name,l_name from user")

	if err != nil {
		t.Fatal(err)
	}
	cid, _ := campaign.Create()
	ProcessSend(
		[]byte(`<a href="https://toomore.net/">1</a><a href="{{WASHI}}https://toomore.net/{{/WASHI}}">2</a>`),
		rows,
		fmt.Sprintf("%s", cid),
		true,
		"Test",
		true,
		4)
}
<commit_msg>Fixed mails send testing<commit_after>package mails

import (
	"fmt"
	"testing"

	"github.com/toomore/mailbox/campaign"
	"github.com/toomore/mailbox/utils"
)

func TestGenParams(t *testing.T) {
	t.Logf("%+v", GenParams("<EMAIL>", "message", "[Test]"))
}

func TestProcessSend(t *testing.T) {
	stmt, err := utils.GetConn().Prepare(`INSERT INTO user(email,groups,f_name,l_name)
	                           VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE f_name=?, l_name=?`)
	if err != nil {
		t.Fatal(err)
	}
	stmt.Exec("<EMAIL>", "test", "Toomore", "Chiang", "Toomore", "Chiang")
	rows, err := utils.GetConn().Query("select id,email,f_name,l_name from user where groups='test'")

	if err != nil {
		t.Fatal(err)
	}
	cid, _ := campaign.Create()
	// Test with dry run
	ProcessSend(
		[]byte(`<a href="https://toomore.net/">1</a><a href="{{WASHI}}https://toomore.net/{{/WASHI}}">2</a>`),
		rows,
		fmt.Sprintf("%s", cid),
		true,
		"Test",
		true,
		4)

	stmt.Exec("to", "test2", "Toomore", "Chiang", "Toomore", "Chiang")
	rows, err = utils.GetConn().Query("select id,email,f_name,l_name from user where groups='test2'")

	if err != nil {
		t.Fatal(err)
	}
	// Test Run
	ProcessSend(
		[]byte(`<a href="https://toomore.net/">1</a><a href="{{WASHI}}https://toomore.net/{{/WASHI}}">2</a>`),
		rows,
		fmt.Sprintf("%s", cid),
		true,
		"Test",
		false,
		4)
}

{'fraction_non_alphanumeric': 0.22619579794367456, 'fraction_numerical': 0.0049172999552972736, 'mean_word_length': 4.086363636363636, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 6, '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': '5858360', 'n_tokens_mistral': 972, 'n_tokens_neox': 903, 'n_words': 164}