<commit_before>package pubsub

import (
	"runtime"
	"testing"
)

type str struct {
	Val string
}

func TestSub(t *testing.T) {
	if Sub(&str{}, func(teststr *str) {}) != nil {
		t.Fail()
	}
	if Sub(&str{}, "String") == nil {
		t.Fail()
	}
}

func TestPublish(t *testing.T) {
	var received string = ""
	Sub(&str{}, func(s *str) {
		received = s.Val
	})
	Pub(&str{Val: "test"})

	runtime.Gosched()
	if received != "test" {
		t.Error("Did not get expected string!")<commit_msg>fixed to use channels<commit_after>package pubsub

import "testing"

type str struct {
	Val string
}

func TestSub(t *testing.T) {
	if Sub(Location, func(teststr *str) {}) != nil {
		t.Fail()
	}

	// Make sure we get an error if we don't pass a func
	if Sub(Location, "String") == nil {
		t.Fail()
	}
}

func TestPublish(t *testing.T) {
	msgs := make(chan string)
	Sub(Location, func(s string) {
		msgs <- s
	})
	Pub(Location, "test")

	msg := <-msgs
	if msg != "test" {
		t.Error("Did not get expected string!")
{'fraction_non_alphanumeric': 0.1766497461928934, 'fraction_numerical': 0.0, 'mean_word_length': 3.5860465116279068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3399774', 'n_tokens_mistral': 400, 'n_tokens_neox': 384, 'n_words': 106}