diff --git a/test/mock_test.go b/test/mock_test.go new file mode 100644 index 0000000..98707e0 --- /dev/null +++ b/test/mock_test.go @@ -0,0 +1,30 @@ +package test + +import ( + "testing" + + "github.com/official-stallion/stallion" +) + +func TestMock(t *testing.T) { + mock := stallion.NewMockClient() + if mock == nil { + t.Error("failed to create mock client") + } + + mock.Subscribe("topic", func(bytes []byte) { + t.Log("successful subscribe") + }) + + err := mock.Publish("topic", []byte("message")) + if err != nil { + t.Error(err) + } + + mock.Unsubscribe("topic") + + err = mock.Publish("topic", []byte("message")) + if err == nil { + t.Error("failed to unsubscribe") + } +}