<commit_before>package pool

import (
	"net/http"
	"testing"
)

var urls = []string{
	"https://google.com",
	"https://yahoo.com",
	"https://httpbin.org",
	"https://golang.org",
}

func fetchURL(args ...interface{}) (interface{}, error) {
	url := args[0].(string)
	resp, err := http.Get(url)

	return resp, err
}

func TestNewPool(t *testing.T) {
	m := make(map[string]bool)
	pool := New(2)
	pool.Run()

	for _, url := range urls {
		pool.Add(fetchURL, url)
		m[url] = true
	}

	for {
		if job, ok := pool.GetResult(); ok {
			// log.Printf("%+v\n", job)
			// Should have a result or an error for each url
			url := job.Args[0]

			if _, ok := m[url.(string)]; ok {
				if job.Result == nil && job.Error == nil {
					t.Errorf("No result or error found for job for url %s",
						url)
				}
			} else {
				t.Errorf("No job found for url: %s", url)
			}

		} else {
			break
		}
	}
}<commit_msg>Working tests<commit_after>package pool

import (
	"net/http"
	"testing"
)

var urls = []string{
	"https://google.com",
	"https://yahoo.com",
	"https://httpbin.org",
	"https://golang.org",
}

func fetchURL(args ...interface{}) (interface{}, error) {
	url := args[0].(string)
	resp, err := http.Get(url)

	return resp, err
}

func TestNewPool(t *testing.T) {
	m := make(map[string]bool)
	pool := NewPool(2)

	for _, url := range urls {
		pool.Add(fetchURL, url)
		m[url] = true
	}

	for i := 0; i < len(urls); i++ {
		job := pool.Result()
		url := job.Args[0]

		if _, ok := m[url.(string)]; ok {
			if job.Result == nil && job.Error == nil {
				t.Errorf("No result or error found for job for url %s",
					url)
			}
		} else {
			t.Errorf("No job found for url: %s", url)
		}

	}
}
{'fraction_non_alphanumeric': 0.19618366129994036, 'fraction_numerical': 0.0041741204531902205, 'mean_word_length': 2.839816933638444, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 8, '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': '6833700', 'n_tokens_mistral': 732, 'n_tokens_neox': 655, 'n_words': 170}