From 003bc1f3de32515606390fb322938605b470de06 Mon Sep 17 00:00:00 2001 From: SimFG Date: Thu, 9 Nov 2023 15:59:09 +0800 Subject: [PATCH] Add GetCDCAPI unit test for the server (#26) Signed-off-by: SimFG --- server/cdc_api.go | 2 +- server/cdc_api_test.go | 6 ++++++ server/server.go | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/cdc_api.go b/server/cdc_api.go index 2807cb03..bd2d352b 100644 --- a/server/cdc_api.go +++ b/server/cdc_api.go @@ -78,6 +78,6 @@ func (b *BaseCDC) List(request *request.ListRequest) (*request.ListResponse, err return nil, nil } -func GetCDCApi(config *CDCServerConfig) CDCService { +func GetCDCAPI(config *CDCServerConfig) CDCService { return NewMetaCDC(config) } diff --git a/server/cdc_api_test.go b/server/cdc_api_test.go index c94d879d..cb6a1521 100644 --- a/server/cdc_api_test.go +++ b/server/cdc_api_test.go @@ -38,3 +38,9 @@ func TestDefaultCDCServer(t *testing.T) { assert.NoError(t, err) } } + +func TestGetCDCAPI(t *testing.T) { + assert.Panics(t, func() { + GetCDCAPI(&CDCServerConfig{}) + }) +} diff --git a/server/server.go b/server/server.go index 4ad9c527..00af64f0 100644 --- a/server/server.go +++ b/server/server.go @@ -43,7 +43,7 @@ func (c *CDCServer) Run(config *CDCServerConfig) { metrics.RegisterMetric() c.serverConfig = config - c.api = GetCDCApi(c.serverConfig) + c.api = GetCDCAPI(c.serverConfig) c.api.ReloadTask() cdcHandler := c.getCDCHandler() http.Handle("/cdc", cdcHandler)