Add go fmt

This commit is contained in:
James Jeffrey
2017-07-07 10:14:08 -07:00
committed by Reed Allman
parent 9a7141967c
commit 81e39b210d
40 changed files with 185 additions and 187 deletions

View File

@@ -8,11 +8,11 @@ import (
"context"
fnclient "github.com/funcy/functions_go/client"
client "gitlab-odx.oracle.com/odx/functions/fn/client"
apiapps "github.com/funcy/functions_go/client/apps"
"github.com/funcy/functions_go/models"
"github.com/jmoiron/jsonq"
"github.com/urfave/cli"
client "gitlab-odx.oracle.com/odx/functions/fn/client"
"strings"
)

View File

@@ -5,10 +5,10 @@ import (
"fmt"
fnclient "github.com/funcy/functions_go/client"
client "gitlab-odx.oracle.com/odx/functions/fn/client"
apicall "github.com/funcy/functions_go/client/call"
"github.com/funcy/functions_go/models"
"github.com/urfave/cli"
client "gitlab-odx.oracle.com/odx/functions/fn/client"
)
type callsCmd struct {

View File

@@ -21,7 +21,6 @@ func EnvAsHeader(req *http.Request, selectedEnv []string) {
}
}
func CallFN(u string, content io.Reader, output io.Writer, method string, env []string) error {
if method == "" {
if content == nil {

View File

@@ -12,13 +12,13 @@ import (
)
var aliases = map[string]cli.Command{
"build": build(),
"bump": bump(),
"deploy": deploy(),
"push": push(),
"run": run(),
"call": call(),
"calls": calls(),
"build": build(),
"bump": bump(),
"deploy": deploy(),
"push": push(),
"run": run(),
"call": call(),
"calls": calls(),
}
func aliasesFn() []cli.Command {

View File

@@ -1,10 +1,10 @@
package main
import (
"gitlab-odx.oracle.com/odx/functions/fn/client"
"net/http"
"os"
"testing"
"gitlab-odx.oracle.com/odx/functions/fn/client"
)
func TestEnvAsHeader(t *testing.T) {

View File

@@ -11,9 +11,9 @@ import (
"strings"
"time"
"gitlab-odx.oracle.com/odx/functions/fn/client"
functions "github.com/funcy/functions_go"
"github.com/urfave/cli"
"gitlab-odx.oracle.com/odx/functions/fn/client"
)
func testfn() cli.Command {

View File

@@ -1,15 +1,14 @@
package tests
import (
"reflect"
"strings"
"testing"
"time"
"strings"
"reflect"
"github.com/funcy/functions_go/client/apps"
)
func TestApps(t *testing.T) {
s := SetupDefaultSuite()
@@ -50,14 +49,14 @@ func TestApps(t *testing.T) {
})
t.Run("create-app-with-config-test", func(t *testing.T) {
CreateApp(t, s.Context, s.Client, s.AppName, map[string]string{"A": "a"})
CreateApp(t, s.Context, s.Client, s.AppName, map[string]string{"A": "a"})
t.Logf("Test `%v` passed.", t.Name())
})
t.Run("inspect-app-with-config-test", func(t *testing.T) {
cfg := &apps.GetAppsAppParams{
Context: s.Context,
App: s.AppName,
App: s.AppName,
}
appPayload, err := s.Client.Apps.GetAppsApp(cfg)
CheckAppResponseError(t, err)
@@ -73,7 +72,7 @@ func TestApps(t *testing.T) {
t.Logf("Test `%v` passed.", t.Name())
})
t.Run("patch-override-app-config", func(t *testing.T){
t.Run("patch-override-app-config", func(t *testing.T) {
config := map[string]string{
"A": "b",
}

View File

@@ -2,13 +2,13 @@ package tests
import (
"bytes"
"testing"
"time"
"net/url"
"path"
"testing"
"time"
"gitlab-odx.oracle.com/odx/functions/fn/client"
"github.com/funcy/functions_go/client/call"
"gitlab-odx.oracle.com/odx/functions/fn/client"
)
func TestCalls(t *testing.T) {
@@ -16,8 +16,8 @@ func TestCalls(t *testing.T) {
t.Run("list-calls-for-missing-app", func(t *testing.T) {
cfg := &call.GetAppsAppCallsRouteParams{
App: s.AppName,
Route: s.RoutePath,
App: s.AppName,
Route: s.RoutePath,
Context: s.Context,
}
_, err := s.Client.Call.GetAppsAppCallsRoute(cfg)
@@ -36,8 +36,8 @@ func TestCalls(t *testing.T) {
t.Run("list-calls-for-missing-route", func(t *testing.T) {
cfg := &call.GetAppsAppCallsRouteParams{
App: s.AppName,
Route: s.RoutePath,
App: s.AppName,
Route: s.RoutePath,
Context: s.Context,
}
_, err := s.Client.Call.GetAppsAppCallsRoute(cfg)
@@ -51,7 +51,7 @@ func TestCalls(t *testing.T) {
t.Run("get-dummy-call", func(t *testing.T) {
cfg := &call.GetCallsCallParams{
Call: "dummy",
Call: "dummy",
Context: s.Context,
}
cfg.WithTimeout(time.Second * 60)
@@ -67,7 +67,7 @@ func TestCalls(t *testing.T) {
callID := CallAsync(t, u, &bytes.Buffer{})
time.Sleep(time.Second * 2)
cfg := &call.GetCallsCallParams{
Call: callID,
Call: callID,
Context: s.Context,
}
cfg.WithTimeout(time.Second * 60)
@@ -84,8 +84,8 @@ func TestCalls(t *testing.T) {
t.Run("list-calls", func(t *testing.T) {
cfg := &call.GetAppsAppCallsRouteParams{
App: s.AppName,
Route: s.RoutePath,
App: s.AppName,
Route: s.RoutePath,
Context: s.Context,
}
calls, err := s.Client.Call.GetAppsAppCallsRoute(cfg)

View File

@@ -1,27 +1,26 @@
package tests
import (
"io"
"encoding/json"
"bytes"
"testing"
"time"
"encoding/json"
"io"
"net/url"
"path"
"strings"
"testing"
"time"
"gitlab-odx.oracle.com/odx/functions/fn/client"
"github.com/funcy/functions_go/client/call"
"github.com/funcy/functions_go/client/operations"
"gitlab-odx.oracle.com/odx/functions/fn/client"
)
type ErrMsg struct {
Message string `json:"message"`
}
type TimeoutBody struct{
Error ErrMsg `json:"error"`
type TimeoutBody struct {
Error ErrMsg `json:"error"`
CallID string `json:"request_id"`
}
@@ -51,7 +50,6 @@ func CallAsync(t *testing.T, u url.URL, content io.Reader) string {
return callID.CallID
}
func TestRouteExecutions(t *testing.T) {
s := SetupDefaultSuite()
newRouteType := "async"
@@ -114,7 +112,7 @@ func TestRouteExecutions(t *testing.T) {
callID := CallAsync(t, u, &bytes.Buffer{})
time.Sleep(time.Second * 2)
cfg := &call.GetCallsCallParams{
Call: callID,
Call: callID,
Context: s.Context,
}
cfg.WithTimeout(time.Second * 60)
@@ -145,7 +143,6 @@ func TestRouteExecutions(t *testing.T) {
DeleteRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)
routePath := "/timeout"
image := "funcy/timeout:0.0.1"
routeType := "sync"
@@ -176,7 +173,7 @@ func TestRouteExecutions(t *testing.T) {
json.NewDecoder(output).Decode(tB)
cfg := &call.GetCallsCallParams{
Call: tB.CallID,
Call: tB.CallID,
Context: s.Context,
}
cfg.WithTimeout(time.Second * 60)
@@ -210,7 +207,7 @@ func TestRouteExecutions(t *testing.T) {
time.Sleep(5 * time.Second)
cfg := &operations.GetCallsCallLogParams{
Call: callID,
Call: callID,
Context: s.Context,
}
@@ -222,11 +219,11 @@ func TestRouteExecutions(t *testing.T) {
t.Fatalf("Log entry must not be empty!")
}
if !strings.Contains(logObj.Payload.Log.Log, "First line") {
t.Fatalf("Log entry must contain `First line` " +
t.Fatalf("Log entry must contain `First line` "+
"string, but got: %v", logObj.Payload.Log.Log)
}
if !strings.Contains(logObj.Payload.Log.Log, "Second line") {
t.Fatalf("Log entry must contain `Second line` " +
t.Fatalf("Log entry must contain `Second line` "+
"string, but got: %v", logObj.Payload.Log.Log)
}
})
@@ -254,7 +251,7 @@ func TestRouteExecutions(t *testing.T) {
time.Sleep(5 * time.Second)
cfg := &operations.GetCallsCallLogParams{
Call: callID,
Call: callID,
Context: s.Context,
}
@@ -283,7 +280,7 @@ func TestRouteExecutions(t *testing.T) {
time.Sleep(5 * time.Second)
cfg := &operations.GetCallsCallLogParams{
Call: callID,
Call: callID,
Context: s.Context,
}
@@ -293,7 +290,7 @@ func TestRouteExecutions(t *testing.T) {
}
if len(logObj.Payload.Log.Log) >= size {
t.Fatalf("Log entry suppose to be truncated up to expected size %v, got %v",
size / 1024, len(logObj.Payload.Log.Log))
size/1024, len(logObj.Payload.Log.Log))
}
})

View File

@@ -1,10 +1,10 @@
package main
import (
"fmt"
"encoding/json"
"os"
"fmt"
"math/rand"
"os"
)
const lBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -13,7 +13,6 @@ type OutputSize struct {
Size int `json:"size"`
}
func RandStringBytes(n int) string {
b := make([]byte, n)
for i := range b {

View File

@@ -6,7 +6,6 @@ import (
"time"
)
func main() {
fmt.Fprintln(os.Stderr, "First line")
fmt.Fprintln(os.Stdout, "Ok")

View File

@@ -28,7 +28,7 @@ func TestRoutes(t *testing.T) {
})
t.Run("can-get-corresponding-route", func(t *testing.T) {
rObjects := []*models.Route{GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath), }
rObjects := []*models.Route{GetRoute(t, s.Context, s.Client, s.AppName, s.RoutePath)}
if !assertContainsRoute(rObjects, s.RoutePath) {
t.Fatalf("Unable to find corresponding route `%v` in list", s.RoutePath)
}

View File

@@ -3,45 +3,43 @@ package tests
import (
"context"
"strings"
"time"
"testing"
"time"
fn "github.com/funcy/functions_go/client"
"github.com/funcy/functions_go/models"
"github.com/funcy/functions_go/client/apps"
"gitlab-odx.oracle.com/odx/functions/fn/client"
"github.com/funcy/functions_go/client/routes"
"github.com/funcy/functions_go/models"
"gitlab-odx.oracle.com/odx/functions/fn/client"
)
type SuiteSetup struct {
Context context.Context
Client *fn.Functions
AppName string
RoutePath string
Image string
RouteType string
Format string
Memory int64
RouteConfig map[string]string
Context context.Context
Client *fn.Functions
AppName string
RoutePath string
Image string
RouteType string
Format string
Memory int64
RouteConfig map[string]string
RouteHeaders map[string][]string
}
func SetupDefaultSuite() *SuiteSetup {
return &SuiteSetup{
Context: context.Background(),
Client: client.APIClient(),
AppName: "test-app",
RoutePath: "/hello",
Image: "funcy/hello",
Format: "default",
RouteType: "async",
RouteConfig: map[string]string{},
Context: context.Background(),
Client: client.APIClient(),
AppName: "test-app",
RoutePath: "/hello",
Image: "funcy/hello",
Format: "default",
RouteType: "async",
RouteConfig: map[string]string{},
RouteHeaders: map[string][]string{},
}
}
func CheckAppResponseError(t *testing.T, err error) {
if err != nil {
switch err.(type) {
@@ -93,12 +91,12 @@ func CheckAppResponseError(t *testing.T, err error) {
}
func CreateAppNoAssert(ctx context.Context, fnclient *fn.Functions, appName string, config map[string]string) (*apps.PostAppsOK, error){
func CreateAppNoAssert(ctx context.Context, fnclient *fn.Functions, appName string, config map[string]string) (*apps.PostAppsOK, error) {
cfg := &apps.PostAppsParams{
Body: &models.AppWrapper{
App: &models.App{
Config: config,
Name: appName,
Name: appName,
},
},
Context: ctx,
@@ -116,14 +114,14 @@ func CreateApp(t *testing.T, ctx context.Context, fnclient *fn.Functions, appNam
}
}
func UpdateApp(t *testing.T, ctx context.Context, fnclient *fn.Functions ,appName string, config map[string]string) *apps.PatchAppsAppOK {
func UpdateApp(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName string, config map[string]string) *apps.PatchAppsAppOK {
CreateApp(t, ctx, fnclient, appName, map[string]string{"A": "a"})
cfg := &apps.PatchAppsAppParams{
App: appName,
Body: &models.AppWrapper{
App: &models.App{
Config: config,
Name: "",
Name: "",
},
},
Context: ctx,
@@ -135,7 +133,7 @@ func UpdateApp(t *testing.T, ctx context.Context, fnclient *fn.Functions ,appNam
func DeleteApp(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName string) {
cfg := &apps.DeleteAppsAppParams{
App: appName,
App: appName,
Context: ctx,
}
cfg.WithTimeout(time.Second * 60)
@@ -143,7 +141,6 @@ func DeleteApp(t *testing.T, ctx context.Context, fnclient *fn.Functions, appNam
CheckAppResponseError(t, err)
}
func CheckRouteResponseError(t *testing.T, err error) {
if err != nil {
switch err.(type) {
@@ -256,11 +253,11 @@ func createRoute(ctx context.Context, fnclient *fn.Functions, appName, image, ro
App: appName,
Body: &models.RouteWrapper{
Route: &models.Route{
Config: routeConfig,
Config: routeConfig,
Headers: headers,
Image: image,
Path: routePath,
Type: routeType,
Image: image,
Path: routePath,
Type: routeType,
},
},
Context: ctx,
@@ -277,10 +274,10 @@ func CreateRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appN
assertRouteFields(t, routeResponse.Payload.Route, routePath, image, routeType)
}
func deleteRoute(ctx context.Context, fnclient *fn.Functions, appName, routePath string) (*routes.DeleteAppsAppRoutesRouteOK, error){
func deleteRoute(ctx context.Context, fnclient *fn.Functions, appName, routePath string) (*routes.DeleteAppsAppRoutesRouteOK, error) {
cfg := &routes.DeleteAppsAppRoutesRouteParams{
App: appName,
Route: routePath,
App: appName,
Route: routePath,
Context: ctx,
}
cfg.WithTimeout(time.Second * 60)
@@ -294,7 +291,7 @@ func DeleteRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appN
func ListRoutes(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName string) []*models.Route {
cfg := &routes.GetAppsAppRoutesParams{
App: appName,
App: appName,
Context: ctx,
}
cfg.WithTimeout(time.Second * 60)
@@ -303,10 +300,10 @@ func ListRoutes(t *testing.T, ctx context.Context, fnclient *fn.Functions, appNa
return routesResponse.Payload.Routes
}
func GetRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName, routePath string) *models.Route{
func GetRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName, routePath string) *models.Route {
cfg := &routes.GetAppsAppRoutesRouteParams{
App: appName,
Route: routePath,
App: appName,
Route: routePath,
Context: ctx,
}
cfg.WithTimeout(time.Second * 60)
@@ -315,7 +312,7 @@ func GetRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName
return routeResponse.Payload.Route
}
func UpdateRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName, routePath, image, routeType, format string, memory int64, routeConfig map[string]string, headers map[string][]string, newRoutePath string) (*routes.PatchAppsAppRoutesRouteOK, error){
func UpdateRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appName, routePath, image, routeType, format string, memory int64, routeConfig map[string]string, headers map[string][]string, newRoutePath string) (*routes.PatchAppsAppRoutesRouteOK, error) {
routeObject := GetRoute(t, ctx, fnclient, appName, routePath)
if routeObject.Config == nil {
@@ -364,7 +361,7 @@ func UpdateRoute(t *testing.T, ctx context.Context, fnclient *fn.Functions, appN
}
cfg := &routes.PatchAppsAppRoutesRouteParams{
App: appName,
App: appName,
Context: ctx,
Body: &models.RouteWrapper{
Route: routeObject,