tidy
This commit is contained in:
@@ -54,7 +54,7 @@ func downloadJar(url *url.URL, outputDir string) (string, error) {
|
||||
}
|
||||
}
|
||||
if uncompressedReader == nil {
|
||||
return "", fmt.Errorf("unable to find .deb data file")
|
||||
return "", errors.New("unable to find .deb data file")
|
||||
}
|
||||
|
||||
tarReader := tar.NewReader(uncompressedReader)
|
||||
@@ -86,7 +86,7 @@ func downloadJar(url *url.URL, outputDir string) (string, error) {
|
||||
}
|
||||
|
||||
if aceJar == nil {
|
||||
return "", fmt.Errorf("unable to find ace.jar")
|
||||
return "", errors.New("unable to find ace.jar")
|
||||
}
|
||||
|
||||
defer aceJar.Close()
|
||||
@@ -192,7 +192,6 @@ func extractJSON(jarFile, fieldsDir string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read file: %w", err)
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Println(file.Name(), file.IsDir())
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestResourceTypes(t *testing.T) {
|
||||
|
||||
err := resource.processJSON(([]byte)(testData))
|
||||
|
||||
assert.Empty(t, err, "No error processing JSON")
|
||||
assert.NoError(t, err, "No error processing JSON")
|
||||
assert.Equal(t, expectation.StructName, resource.StructName)
|
||||
assert.Equal(t, expectation.ResourcePath, resource.ResourcePath)
|
||||
assert.Equal(t, expectation.Types, resource.Types)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -183,7 +184,7 @@ func (c *Client) Login(ctx context.Context, user, pass string) error {
|
||||
c.version = si.Version
|
||||
|
||||
if c.version == "" {
|
||||
return fmt.Errorf("unable to determine controller version")
|
||||
return errors.New("unable to determine controller version")
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -225,7 +226,7 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
|
||||
req.Header.Add("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
if c.csrf != "" {
|
||||
req.Header.Set("X-CSRF-Token", c.csrf)
|
||||
req.Header.Set("X-Csrf-Token", c.csrf)
|
||||
}
|
||||
|
||||
resp, err := c.c.Do(req)
|
||||
@@ -238,8 +239,8 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
|
||||
return &NotFoundError{}
|
||||
}
|
||||
|
||||
if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
|
||||
c.csrf = resp.Header.Get("x-csrf-token")
|
||||
if csrf := resp.Header.Get("X-Csrf-Token"); csrf != "" {
|
||||
c.csrf = resp.Header.Get("X-Csrf-Token")
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
||||
@@ -2,6 +2,7 @@ package unifi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -54,7 +55,7 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, fmt.Errorf("malformed group response")
|
||||
return nil, errors.New("malformed group response")
|
||||
}
|
||||
|
||||
if err := respBody.Data[0].Meta.error(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user