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:
Travis Reeder
2017-09-14 10:57:22 -07:00
committed by GitHub
parent 0f6db73834
commit 9f87b1ead0
81 changed files with 18118 additions and 420 deletions

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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