Skip to content

Commit

Permalink
add: auth server test
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhnajafiz committed Oct 12, 2022
1 parent 6e7d968 commit bbbe3f7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,30 @@ func TestServer(t *testing.T) {
t.Error(err)
}
}

func TestAuthServer(t *testing.T) {
go func() {
if err := stallion.NewServer(":6001", "root", "password"); err != nil {
t.Errorf("server failed to start: %v", err)
}
}()

c, err := stallion.NewClient("st://r:pass@localhost:6001")
if err == nil {
t.Error(err)
}

c, err = stallion.NewClient("st://root:password@localhost:6001")
if err != nil {
t.Error(err)
}

c.Subscribe("topic", func(bytes []byte) {
t.Log("success subscribe")
})

err = c.Publish("topic", []byte("message"))
if err != nil {
t.Error(err)
}
}

0 comments on commit bbbe3f7

Please sign in to comment.