mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-08-31 02:41:34 +00:00
32 lines
713 B
Go
32 lines
713 B
Go
package router
|
|
|
|
import (
|
|
"fmt"
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHostProtocolRegistryDrivesProtocolRoutesOnce(t *testing.T) {
|
|
engine := gin.New()
|
|
SetTaskPluginProtocolRouter(engine)
|
|
|
|
expected := []string{
|
|
"POST /v1/responses",
|
|
"GET /v1/responses/:response_id",
|
|
"POST /v1/videos",
|
|
"GET /v1/videos/:task_id",
|
|
"GET /v1/videos/:task_id/content",
|
|
"HEAD /v1/videos/:task_id/content",
|
|
}
|
|
actual := make([]string, 0, len(engine.Routes()))
|
|
for _, route := range engine.Routes() {
|
|
actual = append(actual, fmt.Sprintf("%s %s", route.Method, route.Path))
|
|
}
|
|
sort.Strings(expected)
|
|
sort.Strings(actual)
|
|
assert.Equal(t, expected, actual)
|
|
}
|