func initRegistryAPI(t *testing.T) (*API, *gin.Engine, *gomock.Controller) {
	api := &API{}
	router := gin.Default()
	mockCtl := gomock.NewController(t)
	mockIM := func(c *gin.Context) { common.NewContext(c).SetNamespace("default") }
	v1 := router.Group("v1")
	{
		configs := v1.Group("/registries")
		configs.GET("/:name", mockIM, common.Wrapper(api.GetRegistry))
		configs.GET("/:name/apps", mockIM, common.Wrapper(api.GetAppByRegistry))
		configs.PUT("/:name", mockIM, common.Wrapper(api.UpdateRegistry))
		configs.POST(":name/refresh", mockIM, common.Wrapper(api.RefreshRegistryPassword))
		configs.DELETE("/:name", mockIM, common.Wrapper(api.DeleteRegistry))
		configs.POST("", mockIM, common.Wrapper(api.CreateRegistry))
		configs.GET("", mockIM, common.Wrapper(api.ListRegistry))
	}
	return api, router, mockCtl
}
TODO: optimize this layer, general abstraction
package api
import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"net/http/httptest"
	"testing"
	"github.com/baetyl/baetyl-go/v2/errors"
	specV1 "github.com/baetyl/baetyl-go/v2/spec/v1"
	"github.com/gin-gonic/gin"
	"github.com/golang/mock/gomock"
	"github.com/stretchr/testify/assert"
	"github.com/baetyl/baetyl-cloud/v2/common"
	mf "github.com/baetyl/baetyl-cloud/v2/mock/facade"
	ms "github.com/baetyl/baetyl-cloud/v2/mock/service"
	"github.com/baetyl/baetyl-cloud/v2/models"
	"github.com/baetyl/baetyl-cloud/v2/service"
)