mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
28 lines
595 B
Go
28 lines
595 B
Go
package handler_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
pb "github.com/micro/services/streams/proto"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestToken(t *testing.T) {
|
|
h := testHandler(t)
|
|
|
|
t.Run("WithoutTopic", func(t *testing.T) {
|
|
var rsp pb.TokenResponse
|
|
err := h.Token(context.TODO(), &pb.TokenRequest{}, &rsp)
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, rsp.Token)
|
|
})
|
|
|
|
t.Run("WithTopic", func(t *testing.T) {
|
|
var rsp pb.TokenResponse
|
|
err := h.Token(context.TODO(), &pb.TokenRequest{Topic: "helloworld"}, &rsp)
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, rsp.Token)
|
|
})
|
|
}
|