Skip to content

Commit

Permalink
add: mock test
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Oct 12, 2022
1 parent bbbe3f7 commit bd3e759
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/mock_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit bd3e759

Please sign in to comment.