<commit_before>package eventbus

import (
	"encoding/json"
	"log"
	"testing"
	"time"
)

type message struct {
	Name string
}

func TestEventBusEmit(t *testing.T) {
	bus, err := NewEventBus()
	if err != nil {
		t.Errorf("Expected to initialize EventBus %s", err)
	}

	if err := bus.Emit("topic", &message{Name: "event"}); err != nil {
		t.Errorf("Expected to emit message %s", err)
	}
}

func TestEventBusOn(t *testing.T) {
	bus, err := NewEventBus()
	if err != nil {
		t.Errorf("Expected to initialize EventBus %s", err)
	}

	testHandler := func(msg []byte) error {
		log.Print("on handler")
		m := message{}
		if err := json.Unmarshal(msg, &m); err != nil {
			t.Errorf("Expected to unmarshal a message %s", err)
		}

		return nil
	}

	if err := bus.On("topic", "channel", testHandler); err != nil {
		t.Errorf("Expected to listen a message %s", err)
	}

	time.Sleep(200 * time.Millisecond)

	if err := bus.Emit("topic", &message{Name: "event"}); err != nil {
		t.Errorf("Expected to emit message %s", err)
	}

	time.Sleep(200 * time.Millisecond)
}
<commit_msg>Remove extra log<commit_after>package eventbus

import (
	"encoding/json"
	"testing"
	"time"
)

type message struct {
	Name string
}

func TestEventBusEmit(t *testing.T) {
	bus, err := NewEventBus()
	if err != nil {
		t.Errorf("Expected to initialize EventBus %s", err)
	}

	if err := bus.Emit("topic", &message{Name: "event"}); err != nil {
		t.Errorf("Expected to emit message %s", err)
	}
}

func TestEventBusOn(t *testing.T) {
	bus, err := NewEventBus()
	if err != nil {
		t.Errorf("Expected to initialize EventBus %s", err)
	}

	testHandler := func(msg []byte) error {
		m := message{}
		if err := json.Unmarshal(msg, &m); err != nil {
			t.Errorf("Expected to unmarshal a message %s", err)
		}

		return nil
	}

	if err := bus.On("topic", "channel", testHandler); err != nil {
		t.Errorf("Expected to listen a message %s", err)
	}

	time.Sleep(200 * time.Millisecond)

	if err := bus.Emit("topic", &message{Name: "event"}); err != nil {
		t.Errorf("Expected to emit message %s", err)
	}

	time.Sleep(200 * time.Millisecond)
}

{'fraction_non_alphanumeric': 0.16953199617956066, 'fraction_numerical': 0.0057306590257879654, 'mean_word_length': 3.805045871559633, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1630079', 'n_tokens_mistral': 804, 'n_tokens_neox': 752, 'n_words': 217}