feat: edge gateway service
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package downstream
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestStaticRouterRoutesExactMessageType(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
want := &stubClient{}
|
||||
router := NewStaticRouter(map[string]Client{
|
||||
"fleet.move": want,
|
||||
})
|
||||
|
||||
got, err := router.Route("fleet.move")
|
||||
require.NoError(t, err)
|
||||
assert.Same(t, want, got)
|
||||
}
|
||||
|
||||
func TestStaticRouterRejectsUnknownMessageType(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
router := NewStaticRouter(map[string]Client{
|
||||
"fleet.move": &stubClient{},
|
||||
})
|
||||
|
||||
_, err := router.Route("fleet.rename")
|
||||
require.ErrorIs(t, err, ErrRouteNotFound)
|
||||
}
|
||||
|
||||
type stubClient struct{}
|
||||
|
||||
func (*stubClient) ExecuteCommand(context.Context, AuthenticatedCommand) (UnaryResult, error) {
|
||||
return UnaryResult{}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user