mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Client generator update (#262)
* Generated a bunch of clients. * Builds go client. * Removed test line. * Changed dependencies to fnproject/fn_go * Fix tests.
This commit is contained in:
@@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/funcy/functions_go/client"
|
||||
"github.com/funcy/functions_go/client/apps"
|
||||
"github.com/funcy/functions_go/models"
|
||||
"github.com/fnproject/fn_go/client"
|
||||
"github.com/fnproject/fn_go/client/apps"
|
||||
"github.com/fnproject/fn_go/models"
|
||||
)
|
||||
|
||||
func CheckAppResponseError(t *testing.T, e error) {
|
||||
@@ -44,7 +44,7 @@ func CheckAppResponseError(t *testing.T, e error) {
|
||||
}
|
||||
}
|
||||
|
||||
func CreateAppNoAssert(ctx context.Context, fnclient *client.Functions, appName string, config map[string]string) (*apps.PostAppsOK, error) {
|
||||
func CreateAppNoAssert(ctx context.Context, fnclient *client.Fn, appName string, config map[string]string) (*apps.PostAppsOK, error) {
|
||||
cfg := &apps.PostAppsParams{
|
||||
Body: &models.AppWrapper{
|
||||
App: &models.App{
|
||||
@@ -66,7 +66,7 @@ func CreateAppNoAssert(ctx context.Context, fnclient *client.Functions, appName
|
||||
return ok, err
|
||||
}
|
||||
|
||||
func CreateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string, config map[string]string) {
|
||||
func CreateApp(t *testing.T, ctx context.Context, fnclient *client.Fn, appName string, config map[string]string) {
|
||||
appPayload, err := CreateAppNoAssert(ctx, fnclient, appName, config)
|
||||
CheckAppResponseError(t, err)
|
||||
if !strings.Contains(appName, appPayload.Payload.App.Name) {
|
||||
@@ -75,7 +75,7 @@ func CreateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, ap
|
||||
}
|
||||
}
|
||||
|
||||
func CreateUpdateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string, config map[string]string) *apps.PatchAppsAppOK {
|
||||
func CreateUpdateApp(t *testing.T, ctx context.Context, fnclient *client.Fn, appName string, config map[string]string) *apps.PatchAppsAppOK {
|
||||
CreateApp(t, ctx, fnclient, appName, map[string]string{"A": "a"})
|
||||
cfg := &apps.PatchAppsAppParams{
|
||||
App: appName,
|
||||
@@ -93,7 +93,7 @@ func CreateUpdateApp(t *testing.T, ctx context.Context, fnclient *client.Functio
|
||||
return appPayload
|
||||
}
|
||||
|
||||
func DeleteApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string) {
|
||||
func DeleteApp(t *testing.T, ctx context.Context, fnclient *client.Fn, appName string) {
|
||||
cfg := &apps.DeleteAppsAppParams{
|
||||
App: appName,
|
||||
Context: ctx,
|
||||
@@ -103,7 +103,7 @@ func DeleteApp(t *testing.T, ctx context.Context, fnclient *client.Functions, ap
|
||||
CheckAppResponseError(t, err)
|
||||
}
|
||||
|
||||
func GetApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string) *models.App {
|
||||
func GetApp(t *testing.T, ctx context.Context, fnclient *client.Fn, appName string) *models.App {
|
||||
cfg := &apps.GetAppsAppParams{
|
||||
App: appName,
|
||||
Context: ctx,
|
||||
@@ -114,7 +114,7 @@ func GetApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appNa
|
||||
return app.Payload.App
|
||||
}
|
||||
|
||||
func DeleteAppNoT(ctx context.Context, fnclient *client.Functions, appName string) {
|
||||
func DeleteAppNoT(ctx context.Context, fnclient *client.Fn, appName string) {
|
||||
cfg := &apps.DeleteAppsAppParams{
|
||||
App: appName,
|
||||
Context: ctx,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/funcy/functions_go/client/apps"
|
||||
"github.com/fnproject/fn_go/client/apps"
|
||||
)
|
||||
|
||||
func TestApps(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/funcy/functions_go/client/call"
|
||||
"github.com/fnproject/fn_go/client/call"
|
||||
)
|
||||
|
||||
func TestCalls(t *testing.T) {
|
||||
@@ -78,21 +78,15 @@ func TestCalls(t *testing.T) {
|
||||
}
|
||||
u.Path = path.Join(u.Path, "r", s.AppName, s.RoutePath)
|
||||
|
||||
callID := CallAsync(t, u, &bytes.Buffer{})
|
||||
time.Sleep(time.Second * 5)
|
||||
cfg := &call.GetCallsCallParams{
|
||||
Call: callID,
|
||||
Context: s.Context,
|
||||
}
|
||||
cfg.WithTimeout(time.Second * 60)
|
||||
_, err := s.Client.Call.GetAppsAppCalls(&call.GetAppsAppCallsParams{
|
||||
App: s.AppName,
|
||||
Route: &s.RoutePath,
|
||||
})
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *call.GetCallsCallNotFound:
|
||||
msg := err.(*call.GetCallsCallNotFound).Payload.Error.Message
|
||||
case *call.GetAppsAppCallsCallNotFound:
|
||||
msg := err.(*call.GetAppsAppCallsCallNotFound).Payload.Error.Message
|
||||
t.Errorf("Unexpected error occurred: %v.", msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/funcy/functions_go/client/call"
|
||||
"github.com/funcy/functions_go/client/operations"
|
||||
"github.com/fnproject/fn_go/client/call"
|
||||
"github.com/fnproject/fn_go/client/operations"
|
||||
)
|
||||
|
||||
type ErrMsg struct {
|
||||
@@ -165,8 +165,8 @@ func TestRouteExecutions(t *testing.T) {
|
||||
callResponse, err := s.Client.Call.GetAppsAppCallsCall(cfg)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
case *call.GetCallsCallNotFound:
|
||||
msg := err.(*call.GetCallsCallNotFound).Payload.Error.Message
|
||||
case *call.GetAppsAppCallsCallNotFound:
|
||||
msg := err.(*call.GetAppsAppCallsCallNotFound).Payload.Error.Message
|
||||
t.Errorf("Unexpected error occurred: %v.", msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/funcy/functions_go/client"
|
||||
"github.com/funcy/functions_go/client/routes"
|
||||
"github.com/funcy/functions_go/models"
|
||||
"github.com/fnproject/fn_go/client"
|
||||
"github.com/fnproject/fn_go/client/routes"
|
||||
"github.com/fnproject/fn_go/models"
|
||||
)
|
||||
|
||||
func CheckRouteResponseError(t *testing.T, e error) {
|
||||
@@ -89,7 +89,7 @@ func assertRouteFields(t *testing.T, routeObject *models.Route, path, image, rou
|
||||
|
||||
}
|
||||
|
||||
func createRoute(ctx context.Context, fnclient *client.Functions, appName, image, routePath, routeType string, routeConfig map[string]string, headers map[string][]string) (*routes.PostAppsAppRoutesOK, error) {
|
||||
func createRoute(ctx context.Context, fnclient *client.Fn, appName, image, routePath, routeType string, routeConfig map[string]string, headers map[string][]string) (*routes.PostAppsAppRoutesOK, error) {
|
||||
cfg := &routes.PostAppsAppRoutesParams{
|
||||
App: appName,
|
||||
Body: &models.RouteWrapper{
|
||||
@@ -118,14 +118,14 @@ func createRoute(ctx context.Context, fnclient *client.Functions, appName, image
|
||||
|
||||
}
|
||||
|
||||
func CreateRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, appName, routePath, image, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) {
|
||||
func CreateRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath, image, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) {
|
||||
routeResponse, err := createRoute(ctx, fnclient, appName, image, routePath, routeType, routeConfig, headers)
|
||||
CheckRouteResponseError(t, err)
|
||||
|
||||
assertRouteFields(t, routeResponse.Payload.Route, routePath, image, routeType, routeFormat)
|
||||
}
|
||||
|
||||
func deleteRoute(ctx context.Context, fnclient *client.Functions, appName, routePath string) (*routes.DeleteAppsAppRoutesRouteOK, error) {
|
||||
func deleteRoute(ctx context.Context, fnclient *client.Fn, appName, routePath string) (*routes.DeleteAppsAppRoutesRouteOK, error) {
|
||||
cfg := &routes.DeleteAppsAppRoutesRouteParams{
|
||||
App: appName,
|
||||
Route: routePath,
|
||||
@@ -135,12 +135,12 @@ func deleteRoute(ctx context.Context, fnclient *client.Functions, appName, route
|
||||
return fnclient.Routes.DeleteAppsAppRoutesRoute(cfg)
|
||||
}
|
||||
|
||||
func DeleteRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, appName, routePath string) {
|
||||
func DeleteRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath string) {
|
||||
_, err := deleteRoute(ctx, fnclient, appName, routePath)
|
||||
CheckRouteResponseError(t, err)
|
||||
}
|
||||
|
||||
func ListRoutes(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string) []*models.Route {
|
||||
func ListRoutes(t *testing.T, ctx context.Context, fnclient *client.Fn, appName string) []*models.Route {
|
||||
cfg := &routes.GetAppsAppRoutesParams{
|
||||
App: appName,
|
||||
Context: ctx,
|
||||
@@ -151,7 +151,7 @@ func ListRoutes(t *testing.T, ctx context.Context, fnclient *client.Functions, a
|
||||
return routesResponse.Payload.Routes
|
||||
}
|
||||
|
||||
func GetRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, appName, routePath string) *models.Route {
|
||||
func GetRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath string) *models.Route {
|
||||
cfg := &routes.GetAppsAppRoutesRouteParams{
|
||||
App: appName,
|
||||
Route: routePath,
|
||||
@@ -163,7 +163,7 @@ func GetRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, app
|
||||
return routeResponse.Payload.Route
|
||||
}
|
||||
|
||||
func UpdateRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, appName, routePath, image, routeType, format string, memory uint64, routeConfig map[string]string, headers map[string][]string, newRoutePath string) (*routes.PatchAppsAppRoutesRouteOK, error) {
|
||||
func UpdateRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath, image, routeType, format string, memory uint64, routeConfig map[string]string, headers map[string][]string, newRoutePath string) (*routes.PatchAppsAppRoutesRouteOK, error) {
|
||||
|
||||
routeObject := GetRoute(t, ctx, fnclient, appName, routePath)
|
||||
if routeObject.Config == nil {
|
||||
@@ -231,7 +231,7 @@ func assertContainsRoute(routeModels []*models.Route, expectedRoute string) bool
|
||||
return false
|
||||
}
|
||||
|
||||
func DeployRoute(t *testing.T, ctx context.Context, fnclient *client.Functions, appName, routePath, image, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) *models.Route {
|
||||
func DeployRoute(t *testing.T, ctx context.Context, fnclient *client.Fn, appName, routePath, image, routeType, routeFormat string, routeConfig map[string]string, headers map[string][]string) *models.Route {
|
||||
cfg := &routes.PutAppsAppRoutesRouteParams{
|
||||
App: appName,
|
||||
Context: ctx,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/fnproject/fn/api/id"
|
||||
"github.com/funcy/functions_go/models"
|
||||
"github.com/fnproject/fn_go/models"
|
||||
)
|
||||
|
||||
func TestRoutes(t *testing.T) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/funcy/functions_go/client"
|
||||
"github.com/fnproject/fn_go/client"
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/spf13/viper"
|
||||
@@ -38,7 +38,7 @@ func Host() string {
|
||||
return u.Host
|
||||
}
|
||||
|
||||
func APIClient() *client.Functions {
|
||||
func APIClient() *client.Fn {
|
||||
transport := httptransport.New(Host(), "/v1", []string{"http"})
|
||||
if os.Getenv("FN_TOKEN") != "" {
|
||||
transport.DefaultAuthentication = httptransport.BearerToken(os.Getenv("FN_TOKEN"))
|
||||
@@ -100,7 +100,7 @@ func getServerWithCancel() (*server.Server, context.CancelFunc) {
|
||||
|
||||
type SuiteSetup struct {
|
||||
Context context.Context
|
||||
Client *client.Functions
|
||||
Client *client.Fn
|
||||
AppName string
|
||||
RoutePath string
|
||||
Image string
|
||||
|
||||
Reference in New Issue
Block a user