Skip to content

Commit

Permalink
gofmt changes
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Dec 20, 2023
1 parent 9b2cb30 commit ef0e3ee
Show file tree
Hide file tree
Showing 56 changed files with 422 additions and 218 deletions.
3 changes: 2 additions & 1 deletion api/api_query_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
package api

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestQueryParams_Select(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import (
"github.com/stretchr/testify/assert"
)

const errResponseFile = "test_data/err_response.json"
const unknownErrResponseFile = "test_data/unknown_error.txt"
const (
errResponseFile = "test_data/err_response.json"
unknownErrResponseFile = "test_data/unknown_error.txt"
)

func buildResp(t *testing.T, path string, statusCode int) *http.Response {
data, err := os.Open(path)

if err != nil {
t.FailNow()
}
Expand Down Expand Up @@ -115,7 +116,8 @@ func TestClient_Query(t *testing.T) {
reqBody["foo"] = "bar"
resp := &testResp{}
_, err := c.Query(ctx, RequestConfig{
Method: "POST", Endpoint: testURL, ID: id, Action: action, QueryParams: &qp, Body: reqBody}, resp)
Method: "POST", Endpoint: testURL, ID: id, Action: action, QueryParams: &qp, Body: reqBody,
}, resp)
assert.Nil(t, err)
assert.Equal(t, resp.Name, "Foo")
}
Expand Down Expand Up @@ -163,7 +165,6 @@ func TestClientIMPL_updatePaginationInfoInMeta(t *testing.T) {
header.Set(paginationHeader, "b-bb/aaa")
c.updatePaginationInfoInMeta(&meta, resp)
assert.False(t, meta.Pagination.IsPaginate)

}

type qpTest struct{}
Expand Down Expand Up @@ -247,7 +248,7 @@ func (s stubTypeWithMetaData) MetaData() http.Header {
}

func Test_addMetaData(t *testing.T) {
var tests = []struct {
tests := []struct {
name string
givenRequest *http.Request
expectedRequest *http.Request
Expand Down
3 changes: 2 additions & 1 deletion api/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package api

import (
"context"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestContextTraceId(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion api/throttling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package api

import (
"context"
"github.com/stretchr/testify/assert"
"testing"
"time"

"github.com/stretchr/testify/assert"
)

func TestSemaphore(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ func NewClient() (Client, error) {
// NewClientWithArgs returns new PowerStore API client initialized from args
func NewClientWithArgs(
apiURL string,
username, password string, options *ClientOptions) (Client, error) {
username, password string, options *ClientOptions,
) (Client, error) {
client, err := api.New(apiURL, username, password,
options.Insecure(), options.DefaultTimeout(), options.RateLimit(), options.RequestIDKey())
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion client_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
package gopowerstore

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestClientOptions_Insecure(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package gopowerstore

import (
"context"
"github.com/stretchr/testify/assert"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

var C Client
Expand Down
3 changes: 2 additions & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func (c *ClientIMPL) GetRemoteSystemByName(ctx context.Context, name string) (re
RequestConfig{
Method: "GET",
Endpoint: remoteSystemURL,
QueryParams: qp},
QueryParams: qp,
},
&systemList)
err = WrapErr(err)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package gopowerstore
import (
"context"
"fmt"
"testing"

"github.com/jarcoal/httpmock"
"github.com/stretchr/testify/assert"
"testing"
)

const (
Expand Down
13 changes: 8 additions & 5 deletions examples/client_side_extend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ package main
import (
"context"
"fmt"
"github.com/dell/gopowerstore"
"os"

"github.com/dell/gopowerstore"
)

func initClient() gopowerstore.Client {
Expand Down Expand Up @@ -61,15 +62,16 @@ func (myc *MyClient) GetMyFavoriteVolume(ctx context.Context) (resp gopowerstore
Method: "GET",
Endpoint: "volume",
ID: favVolID,
QueryParams: qp},
QueryParams: qp,
},
&resp)
return

}

// GetVolumesByNamePrefix returns list of volumes witch names start from prefix
func (myc *MyClient) GetVolumesByNamePrefix(ctx context.Context,
prefix string) (resp []gopowerstore.Volume, err error) {
prefix string,
) (resp []gopowerstore.Volume, err error) {
apiClient := myc.APIClient()
qp := apiClient.QueryParams()
qp.Select("id", "name")
Expand All @@ -79,7 +81,8 @@ func (myc *MyClient) GetVolumesByNamePrefix(ctx context.Context,
gopowerstore.RequestConfig{
Method: "GET",
Endpoint: "volume",
QueryParams: qp},
QueryParams: qp,
},
&resp)
return
}
Expand Down
10 changes: 7 additions & 3 deletions fc_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package gopowerstore

import (
"context"

"github.com/dell/gopowerstore/api"

log "github.com/sirupsen/logrus"
Expand All @@ -34,7 +35,8 @@ func getFCPortDefaultQueryParams(c Client) api.QueryParamsEncoder {

// GetFCPorts returns a list of fc ports for array
func (c *ClientIMPL) GetFCPorts(
ctx context.Context) (resp []FcPort, err error) {
ctx context.Context,
) (resp []FcPort, err error) {
err = c.readPaginatedData(func(offset int) (api.RespMeta, error) {
var page []FcPort
qp := getFCPortDefaultQueryParams(c)
Expand All @@ -55,7 +57,8 @@ func (c *ClientIMPL) GetFCPorts(
RequestConfig{
Method: "GET",
Endpoint: apiFCPortURL,
QueryParams: qp},
QueryParams: qp,
},
&page)
err = WrapErr(err)
if err == nil {
Expand All @@ -74,7 +77,8 @@ func (c *ClientIMPL) GetFCPort(ctx context.Context, id string) (resp FcPort, err
Method: "GET",
Endpoint: apiFCPortURL,
ID: id,
QueryParams: getFCPortDefaultQueryParams(c)},
QueryParams: getFCPortDefaultQueryParams(c),
},
&resp)
return resp, WrapErr(err)
}
9 changes: 6 additions & 3 deletions fc_port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ package gopowerstore
import (
"context"
"fmt"
"testing"

"github.com/jarcoal/httpmock"
"github.com/stretchr/testify/assert"
"testing"
)

const (
fcPortMockURL = APIMockURL + apiFCPortURL
)

var fcPortID = "9197cba085b04a86b63a17267b11d1e6"
var fcPortID2 = "5c8af4bd7e4542418b9a5ec857912a28"
var (
fcPortID = "9197cba085b04a86b63a17267b11d1e6"
fcPortID2 = "5c8af4bd7e4542418b9a5ec857912a28"
)

func TestClientIMPL_GetFCPorts(t *testing.T) {
httpmock.Activate()
Expand Down
6 changes: 4 additions & 2 deletions fc_port_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ type FcPortModify struct {

// Fields returns fields which must be requested to fill struct
func (h *FcPort) Fields() []string {
return []string{"appliance_id", "current_speed", "id",
return []string{
"appliance_id", "current_speed", "id",
"io_module_id", "is_link_up", "name", "node_id", "partner_id",
"port_index", "requested_speed", "sfp_id", "supported_speeds", "wwn"}
"port_index", "requested_speed", "sfp_id", "supported_speeds", "wwn",
}
}
Loading

0 comments on commit ef0e3ee

Please sign in to comment.