func TestScaleDownClusterCallback(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().ScaleDownCallback(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/scaledown/callback",
			expectStatus: http.StatusOK,
		},
	}
	callback := &types.Callback{}
	body, _ := json.Marshal(callback)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
scale down callback
package cluster_test
import (
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"
	"github.com/gosoon/kubernetes-operator/pkg/server/controller"
	"github.com/gosoon/kubernetes-operator/pkg/server/controller/cluster"
	"github.com/gosoon/kubernetes-operator/pkg/test/mock_service"
	"github.com/gosoon/kubernetes-operator/pkg/types"
	"github.com/golang/mock/gomock"
	"github.com/gorilla/mux"
	"github.com/stretchr/testify/assert"
)
func TestCreateCluster(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().CreateCluster(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster",
			body:         "",
			expectStatus: http.StatusOK,
		},
	}
	client := &types.EcsClient{}
	body, _ := json.Marshal(client)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestDeleteCluster(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().DeleteCluster(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "DELETE",
			url:          "/api/v1/region/default/cluster/test-cluster",
			expectStatus: http.StatusOK,
		},
	}
	client := &types.EcsClient{}
	body, _ := json.Marshal(client)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestScaleUpCluster(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().ScaleUp(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/scaleup",
			expectStatus: http.StatusOK,
		},
	}
	client := &types.EcsClient{}
	body, _ := json.Marshal(client)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestScaleDownCluster(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().ScaleDown(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/scaledown",
			expectStatus: http.StatusOK,
		},
	}
	client := &types.EcsClient{}
	body, _ := json.Marshal(client)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestCreateClusterCallback(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().CreateClusterCallback(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/create/callback",
			expectStatus: http.StatusOK,
		},
	}
	callback := &types.Callback{}
	body, _ := json.Marshal(callback)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestDeleteClusterCallback(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().DeleteClusterCallback(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/delete/callback",
			expectStatus: http.StatusOK,
		},
	}
	callback := &types.Callback{}
	body, _ := json.Marshal(callback)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}
func TestScaleUpClusterCallback(t *testing.T) {
	ctrl := gomock.NewController(t)
	defer ctrl.Finish()
	mockService := mock_service.NewMockInterface(ctrl)
	mockService.EXPECT().ScaleUpCallback(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
	router := mux.NewRouter()
	cluster.New(&controller.Options{Service: mockService}).Register(router.PathPrefix("").Subrouter())
	testCases := []struct {
		method       string
		url          string
		body         string
		expectStatus int
		expectBody   string
	}{
		{
			method:       "POST",
			url:          "/api/v1/region/default/cluster/test-cluster/scaleup/callback",
			expectStatus: http.StatusOK,
		},
	}
	callback := &types.Callback{}
	body, _ := json.Marshal(callback)
	for _, test := range testCases {
		req := httptest.NewRequest(test.method, test.url, strings.NewReader(string(body)))
		w := httptest.NewRecorder()
		router.ServeHTTP(w, req)
		if !assert.Equal(t, test.expectStatus, w.Code) {
			t.Errorf("expect %v, got %v", test.expectStatus, w.Code)
		}
	}
}