<commit_before>package main

import (
	"net/url"
	"testing"

	"github.com/andygrunwald/go-trending"
	"github.com/google/go-github/github"
)

func TestTweets_IsProjectEmpty(t *testing.T) {
	ts := TweetSearch{}
	mock := []struct {
		Project trending.Project
		Result  bool
	}{
		{trending.Project{Name: ""}, true},
		{trending.Project{Name: "MyProject"}, false},
	}

	for _, item := range mock {
		res := ts.IsProjectEmpty(item.Project)
		if res != item.Result {
			t.Errorf("Failed for project \"%s\", got %v, expected %v", item.Project.Name, res, item.Result)
		}
	}
}

func TestTweets_BuildTweet(t *testing.T) {
	owner := "andygrunwald"
	repositoryName := "TrendingGithub"
	projectName := owner + "/" + repositoryName
	projectURL, _ := url.Parse("https://github.com/andygrunwald/TrendingGithub")
	projectDescription := "A twitter bot (@TrendingGithub) to tweet trending repositories and developers from GitHub"

	ts := TweetSearch{
		URLLength: 24,
	}

	stars := 123
	repository := &github.Repository{
		StargazersCount: &(stars),
	}

	mock := []struct {
		Project trending.Project
		Result  string
	}{
		//{trending.Project{Name: ""}, "true"},
		/*
			{trending.Project{
				Name:        "SuperDuperOwnerOrOrganisation/This-Is-A-Super-Long-Project-Name-That-Will-Maybe-Kill-My-Tweet-Generation-But-I-Think-It-Is-Useful-To-Test",
				Description: projectDescription + " and more and better and super duper text",
				Language:    "Go",
				URL:         projectURL,
			}, "andygrunwald/TrendingGithub - A twitter bot (@TrendingGithub) to tweet trending repositories and developers... https://github.com/andygrunwald/TrendingGithub #Go"},
		*/
		{trending.Project{
			Name:           "SuperDuperOwnerOrOrganisation/This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project",
			Owner:          "SuperDuperOwnerOrOrganisation",
			RepositoryName: "This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project",
			Description:    projectDescription + " and more and better and super duper text",
			Language:       "Go",
			URL:            projectURL,
		}, "SuperDuperOwnerOrOrganisation/This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project ★123 https://github.com/andygrunwald/TrendingGithub #Go"},
		{trending.Project{
			Name:           projectName + "-cool-super-project",
			Owner:          owner,
			RepositoryName: repositoryName + "-cool-super-project",
			Description:    projectDescription + " and more and better and super duper text",
			Language:       "Go",
			URL:            projectURL,
		}, "andygrunwald/TrendingGithub-cool-super-project: A twitter bot (@TrendingGithub) to tweet trending... ★123 https://github.com/andygrunwald/TrendingGithub #Go"},
		{trending.Project{
			Name:           projectName,
			Owner:          owner,
			RepositoryName: repositoryName,
			Description:    projectDescription,
			Language:       "Go",
			URL:            projectURL,<commit_msg>Fixed unit test<commit_after>package main

import (
	"net/url"
	"testing"

	"github.com/andygrunwald/go-trending"
	"github.com/andygrunwald/TrendingGithub/github"
)

func TestTweets_IsProjectEmpty(t *testing.T) {
	ts := TweetSearch{}
	mock := []struct {
		Project trending.Project
		Result  bool
	}{
		{trending.Project{Name: ""}, true},
		{trending.Project{Name: "MyProject"}, false},
	}

	for _, item := range mock {
		res := ts.IsProjectEmpty(item.Project)
		if res != item.Result {
			t.Errorf("Failed for project \"%s\", got %v, expected %v", item.Project.Name, res, item.Result)
		}
	}
}

func TestTweets_BuildTweet(t *testing.T) {
	owner := "andygrunwald"
	repositoryName := "TrendingGithub"
	projectName := owner + "/" + repositoryName
	projectURL, _ := url.Parse("https://github.com/andygrunwald/TrendingGithub")
	projectDescription := "A twitter bot (@TrendingGithub) to tweet trending repositories and developers from GitHub"

	ts := TweetSearch{
		URLLength: 24,
	}

	stars := 123
	repository := &github.Repository{
		StargazersCount: &(stars),
	}

	mock := []struct {
		Project trending.Project
		Result  string
	}{
		{trending.Project{
			Name:           "SuperDuperOwnerOrOrganisation/This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project",
			Owner:          "SuperDuperOwnerOrOrganisation",
			RepositoryName: "This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project",
			Description:    projectDescription + " and more and better and super duper text",
			Language:       "Go",
			URL:            projectURL,
		}, "SuperDuperOwnerOrOrganisation/This-Is-A-Long-Project-Name-That-Will-Drop-The-Description-Of-The-Project ★123 https://github.com/andygrunwald/TrendingGithub #Go"},
		{trending.Project{
			Name:           projectName + "-cool-super-project",
			Owner:          owner,
			RepositoryName: repositoryName + "-cool-super-project",
			Description:    projectDescription + " and more and better and super duper text",
			Language:       "Go",
			URL:            projectURL,
		}, "andygrunwald/TrendingGithub-cool-super-project: A twitter bot (@TrendingGithub) to tweet trending... ★123 https://github.com/andygrunwald/TrendingGithub #Go"},
		{trending.Project{
			Name:           projectName,
			Owner:          owner,
			RepositoryName: repositoryName,
			Description:    projectDescription,
			Language:       "Go",
			URL:            projectURL,
{'fraction_non_alphanumeric': 0.13462976813762154, 'fraction_numerical': 0.004113687359760658, 'mean_word_length': 3.4612176814011675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, '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': '5140188', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1759, 'n_words': 345}