Skip to content

Commit

Permalink
increase line length
Browse files Browse the repository at this point in the history
  • Loading branch information
GomathiselviS committed Jan 16, 2024
1 parent c24e6df commit 8068676
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
line-length: 160
misspell:
locale: US
nolintlint:
Expand Down Expand Up @@ -72,4 +72,4 @@ issues:

run:
timeout: 5m
skip-dirs: []
skip-dirs: []
1 change: 0 additions & 1 deletion internal/provider/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func NewClient(host string, username *string, password *string, insecureSkipVeri
Password: password,
}


tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: insecureSkipVerify},
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (d *GroupResourceModel) ParseHttpResponse(body []byte) error {
/* Unmarshal the json string */
result := make(map[string]interface{})

err := json.Unmarshal([]byte(body), &result)
err := json.Unmarshal(body, &result)
if err != nil {
return err
}
Expand All @@ -147,7 +147,7 @@ func (d *GroupResourceModel) ParseHttpResponse(body []byte) error {
}

// Configure adds the provider configured client to the resource.
func (d *GroupResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
func (d *GroupResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
if req.ProviderData == nil {
return
}
Expand Down
21 changes: 13 additions & 8 deletions internal/provider/group_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestGroupParseHttpResponse(t *testing.T) {
body := []byte("Not valid JSON")
err := g.ParseHttpResponse(body)
assert.Error(t, err)

})
}

Expand Down Expand Up @@ -77,7 +76,6 @@ func TestGroupCreateRequestBody(t *testing.T) {
}

bytes.Equal(result, []byte(nil))

})
t.Run("All Values", func(t *testing.T) {
g := GroupResourceModel{
Expand All @@ -87,31 +85,39 @@ func TestGroupCreateRequestBody(t *testing.T) {
Variables: jsontypes.NewNormalizedValue("{\"ansible_network_os\":\"ios\"}"),
Description: types.StringValue("New Group"),
}
body := []byte(`{"name": "group1", "inventory": 5, "url": "/api/v2/groups/24/", "description": "New Group", "variables": "{\"ansible_network_os\":\"ios\"}"}`)
body := []byte(`{"name": "group1", "inventory": 5,
"url": "/api/v2/groups/24/",
"description": "New Group",
"variables": "{\"ansible_network_os\":\"ios\"}"}`)

result, diags := g.CreateRequestBody()
if diags.HasError() {
t.Fatal(diags.Errors())
}
assert.JSONEq(t, string(body), string(result))

})
t.Run("Multiple values for Variables", func(t *testing.T) {
g := GroupResourceModel{
InventoryId: basetypes.NewInt64Value(5),
Name: types.StringValue("group1"),
URL: types.StringValue("/api/v2/groups/24/"),
Variables: jsontypes.NewNormalizedValue("{\"ansible_network_os\":\"ios\", \"ansible_connection\":\"network_cli\", \"ansible_ssh_user\":\"ansible\", \"ansible_ssh_pass\":\"ansible\"}"),
Variables: jsontypes.NewNormalizedValue(
"{\"ansible_network_os\":\"ios\",\"ansible_connection\":\"network_cli\", \"ansible_ssh_user\":\"ansible\", \"ansible_ssh_pass\":\"ansible\"}",
),
Description: types.StringValue("New Group"),
}
body := []byte(`{"name": "group1", "inventory": 5, "url": "/api/v2/groups/24/", "description": "New Group", "variables": "{\"ansible_network_os\":\"ios\", \"ansible_connection\":\"network_cli\", \"ansible_ssh_user\":\"ansible\", \"ansible_ssh_pass\":\"ansible\"}"}`)
body := []byte(`{"name": "group1", "inventory": 5,
"url": "/api/v2/groups/24/",
"description": "New Group",
"variables":
"{\"ansible_network_os\":\"ios\", \"ansible_connection\":\"network_cli\", \"ansible_ssh_user\":\"ansible\", \"ansible_ssh_pass\":\"ansible\"}"}`,
)

result, diags := g.CreateRequestBody()
if diags.HasError() {
t.Fatal(diags.Errors())
}
assert.JSONEq(t, string(body), string(result))

})
}

Expand Down Expand Up @@ -232,6 +238,5 @@ func TestReadGroup(t *testing.T) {
if err == nil {
t.Errorf("Failure expected but the ReadJob did not fail!!")
}

})
}
1 change: 0 additions & 1 deletion internal/provider/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func mergeStringMaps(m1 map[string]string, m2 map[string]string) map[string]stri
}

func (c *MockHTTPClient) doRequest(method string, path string, data io.Reader) (*http.Response, []byte, error) {

if !slices.Contains(c.acceptMethods, method) {
return nil, nil, nil
}
Expand Down

0 comments on commit 8068676

Please sign in to comment.