Skip to content

Commit

Permalink
format lines
Browse files Browse the repository at this point in the history
Signed-off-by: Neil Shen <[email protected]>
  • Loading branch information
overvenus committed Jan 27, 2022
1 parent ed487cc commit 0388065
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions cdc/api/open_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func newStatusProvider() *mockStatusProvider {
Return(map[model.CaptureID]*model.TaskStatus{captureID: {}}, nil)

statusProvider.On("GetTaskPositions", mock.Anything).
Return(map[model.CaptureID]*model.TaskPosition{captureID: {Error: &model.RunningError{Message: "test"}}}, nil)
Return(map[model.CaptureID]*model.TaskPosition{
captureID: {Error: &model.RunningError{Message: "test"}},
}, nil)

statusProvider.On("GetAllChangeFeedStatuses", mock.Anything).
Return(map[model.ChangeFeedID]*model.ChangeFeedStatus{
Expand Down Expand Up @@ -239,7 +241,9 @@ func TestPauseChangefeed(t *testing.T) {
require.Contains(t, respErr.Error, "changefeed not exists")

// test pause changefeed failed
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/pause", nonExistChangefeedID), method: "POST"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/pause", nonExistChangefeedID),
method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand Down Expand Up @@ -289,7 +293,9 @@ func TestResumeChangefeed(t *testing.T) {
require.Contains(t, respErr.Error, "changefeed not exists")

// test resume changefeed failed
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/resume", nonExistChangefeedID), method: "POST"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/resume", nonExistChangefeedID),
method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand Down Expand Up @@ -339,7 +345,9 @@ func TestRemoveChangefeed(t *testing.T) {
require.Contains(t, respErr.Error, "changefeed not exists")

// test remove changefeed failed
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s", nonExistChangefeedID), method: "DELETE"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s", nonExistChangefeedID),
method: "DELETE"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand All @@ -364,7 +372,9 @@ func TestRebalanceTable(t *testing.T) {
require.EqualValues(t, cfID, changeFeedID)
close(done)
})
api := testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/rebalance_table", changeFeedID), method: "POST"}
api := testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/rebalance_table", changeFeedID),
method: "POST"}
w := httptest.NewRecorder()
req, _ := http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand All @@ -391,7 +401,9 @@ func TestRebalanceTable(t *testing.T) {
require.Contains(t, respErr.Error, "changefeed not exists")

// test rebalance table failed
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/rebalance_table", nonExistChangefeedID), method: "POST"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/rebalance_table", nonExistChangefeedID),
method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand Down Expand Up @@ -429,7 +441,9 @@ func TestMoveTable(t *testing.T) {
require.EqualValues(t, tableID, data.TableID)
close(done)
})
api := testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", changeFeedID), method: "POST"}
api := testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", changeFeedID),
method: "POST"}
w := httptest.NewRecorder()
req, _ := http.NewRequest(api.method, api.url, body)
router.ServeHTTP(w, req)
Expand All @@ -455,7 +469,9 @@ func TestMoveTable(t *testing.T) {
done <- cerror.ErrChangeFeedNotExists.FastGenByArgs(cfID)
close(done)
})
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", changeFeedID), method: "POST"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", changeFeedID),
method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, body)
router.ServeHTTP(w, req)
Expand All @@ -466,7 +482,9 @@ func TestMoveTable(t *testing.T) {
require.Contains(t, respErr.Error, "changefeed not exists")

// test move table failed
api = testCase{url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", nonExistChangefeedID), method: "POST"}
api = testCase{
url: fmt.Sprintf("/api/v1/changefeeds/%s/tables/move_table", nonExistChangefeedID),
method: "POST"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, body)
router.ServeHTTP(w, req)
Expand Down Expand Up @@ -499,7 +517,9 @@ func TestGetProcessor(t *testing.T) {
cp := capture.NewCapture4Test(mo)
router := newRouter(cp, newStatusProvider())
// test get processor succeeded
api := testCase{url: fmt.Sprintf("/api/v1/processors/%s/%s", changeFeedID, captureID), method: "GET"}
api := testCase{
url: fmt.Sprintf("/api/v1/processors/%s/%s", changeFeedID, captureID),
method: "GET"}
w := httptest.NewRecorder()
req, _ := http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand All @@ -510,7 +530,9 @@ func TestGetProcessor(t *testing.T) {
require.Equal(t, "test", processorDetail.Error.Message)

// test get processor fail due to capture ID error
api = testCase{url: fmt.Sprintf("/api/v1/processors/%s/%s", changeFeedID, "non-exist-capture"), method: "GET"}
api = testCase{
url: fmt.Sprintf("/api/v1/processors/%s/%s", changeFeedID, "non-exist-capture"),
method: "GET"}
w = httptest.NewRecorder()
req, _ = http.NewRequest(api.method, api.url, nil)
router.ServeHTTP(w, req)
Expand Down

0 comments on commit 0388065

Please sign in to comment.