Skip to content

Commit aee31fe

Browse files
authored
Fix lint errors (#232)
Signed-off-by: Andy Bavier <andybavier@gmail.com>
1 parent cae25e8 commit aee31fe

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ linters:
1212
- dogsled
1313
- unconvert
1414
# - nakedret
15-
- exportloopref
15+
- copyloopvar
1616
issues:
1717
exclude-use-default: false
1818
exclude:

pkg/utils/rpcerror_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
package utils
77

88
import (
9-
"fmt"
9+
"errors"
10+
"net/http"
11+
"testing"
12+
1013
"github.com/labstack/echo/v4"
1114
"google.golang.org/grpc/codes"
1215
"google.golang.org/grpc/status"
1316
"gotest.tools/assert"
14-
"net/http"
15-
"testing"
1617
)
1718

1819
func Test_ConvertGRPCError(t *testing.T) {
@@ -31,54 +32,54 @@ func Test_ConvertHttpError(t *testing.T) {
3132

3233
func Test_ConvertGrpcError_NoContent(t *testing.T) {
3334
validationErrMsg := respInternalInvalid + ` test1`
34-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
35+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
3536
assert.Error(t, httpError, "code=204, message=rpc error: code = Internal desc = rpc error: code = InvalidArgument test1")
3637
}
3738

3839
func Test_ConvertGrpcError_Leafref(t *testing.T) {
3940
validationErrMsg := respInvalidValidation + ` Application value starbucks-nvr (string ptr) schema path /a/b/c has leafref path /d/e/f not equal to any target nodes, field name Application value starbucks-nvr (string ptr) schema path /a/b/c has leafref path /d/e/f not equal to any target nodes`
40-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
41+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
4142
assert.Error(t, httpError, "code=400, message=Change gives LeafRef error on /d/e/f. Application value starbucks-nvr not present. From path: /a/b/c")
4243
}
4344

4445
func Test_ConvertGrpcError_ValidationOther(t *testing.T) {
4546
validationErrMsg := respInvalidValidation + ` test1234` + notEqual
46-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
47+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
4748
assert.Error(t, httpError, "code=400, message=test1234")
4849
}
4950

5051
func Test_ConvertGrpcError_ValidationOther1(t *testing.T) {
5152
validationErrMsg := respInvalidValidation + ` test1234 (test abc)` + " " + schemaPath + " /a/b/c " + hasLrPath + " /d/e/f " + notEqual + " " + notEqual
52-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
53+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
5354
assert.Error(t, httpError, "code=400, message=Change gives LeafRef error on /d/e/f. test1234 not present. From path: /a/b/c")
5455
}
5556

5657
func Test_ConvertGrpcError_ValidationNotRepeated(t *testing.T) {
5758
validationErrMsg := respInvalidValidation + ` test1234 (test abc)` + " " + schemaPath + " /a/b/c " + hasLrPath + " /d/e/f " + notEqual
58-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
59+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
5960
assert.Error(t, httpError, "code=400, message=Change gives LeafRef error on /d/e/f. test1234 not present. From path: /a/b/c")
6061
}
6162

6263
func Test_ConvertGrpcError_ValidationNoBracket(t *testing.T) {
6364
validationErrMsg := respInvalidValidation + ` test1234 test abc)` + " " + schemaPath + " /a/b/c " + hasLrPath + " /d/e/f " + notEqual
64-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
65+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
6566
assert.Error(t, httpError, "code=400, message=test1234 test abc) schema path /a/b/c has leafref path /d/e/f ")
6667
}
6768

6869
func Test_ConvertGrpcError_InvalidOther(t *testing.T) {
6970
validationErrMsg := respInvalidBase + ` test1234`
70-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
71+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
7172
assert.Error(t, httpError, "code=400, message=rpc error: code = InvalidArgument desc = test1234")
7273
}
7374

7475
func Test_ConvertGrpcError_Unauthorized(t *testing.T) {
7576
validationErrMsg := respUnauthorized + ` test1234`
76-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
77+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
7778
assert.Error(t, httpError, "code=401, message=rpc error: code = Unauthenticated desc = test1234")
7879
}
7980

8081
func Test_ConvertGrpcError_Internal(t *testing.T) {
8182
validationErrMsg := `rpc error: code = test1234`
82-
httpError := ConvertGrpcError(fmt.Errorf(validationErrMsg))
83+
httpError := ConvertGrpcError(errors.New(validationErrMsg))
8384
assert.Error(t, httpError, "code=500, message=rpc error: code = test1234")
8485
}

0 commit comments

Comments
 (0)