Commit 0eb252c7 authored by Vihang Mehta's avatar Vihang Mehta
Browse files

Enable predeclared golangci-lint linter

Summary: TSIA

Test Plan: `CGO_ENABLED=0 golangci-lint run` reports no errors

Reviewers: zasgar

Reviewed By: zasgar

Differential Revision: https://phab.corp.pixielabs.ai/D7911

GitOrigin-RevId: 06c6b9f5d81278c893920c75e39647987720f65a
parent 8249e45e
Showing with 23 additions and 22 deletions
+23 -22
......@@ -21,6 +21,7 @@ linters:
- misspell
- nakedret
- nolintlint
- predeclared
- staticcheck
- structcheck
- typecheck
......
......@@ -338,8 +338,8 @@ func createLoginRequest(t *testing.T, hydraLoginState, loginChallenge string) *h
}
func TestRedirectToLogin(t *testing.T) {
c, close := makeClient(t)
defer close()
c, cleanup := makeClient(t)
defer cleanup()
req := createLoginRequest(t, "", "abcd")
......@@ -384,11 +384,11 @@ func TestAcceptHydraLogin(t *testing.T) {
// Call the original login request to handle the rest.
return (&fakeHydraAdminClient{}).AcceptLoginRequest(params)
}
c, close := makeClient(t)
c, cleanup := makeClient(t)
c.hydraAdminClient = &fakeHydraAdminClient{
acceptLoginRequestFn: &acceptLoginRequestFn,
}
defer close()
defer cleanup()
// Fake whoami response.
whoami := &Whoami{
......@@ -430,8 +430,8 @@ func TestInterceptHydraConsent(t *testing.T) {
hydraPublicHostCookie := "coolcookie"
p := fillDefaults(&testClientConfig{consentChallenge: consentChallenge, hydraPublicHostCookie: hydraPublicHostCookie})
c, close := makeClientFromConfig(t, p)
defer close()
c, cleanup := makeClientFromConfig(t, p)
defer cleanup()
consentURL := p.hydraBrowserURL + p.hydraConsentPath
......@@ -510,11 +510,11 @@ func TestAcceptConsentWithWrongClientID(t *testing.T) {
func TestHandleLogin(t *testing.T) {
postLoginRedirect := "/auth/callback"
consentRedirectCookie := "consentRedirectCookie"
c, close := makeClientFromConfig(t, &testClientConfig{
c, cleanup := makeClientFromConfig(t, &testClientConfig{
postLoginRedirect: postLoginRedirect,
hydraPublicHostCookie: consentRedirectCookie,
})
defer close()
defer cleanup()
hydraLoginState := "abcdef"
loginChallenge := "ghijkl"
......@@ -558,8 +558,8 @@ func getRedirectURL(t *testing.T, resp *http.Response) string {
func TestHandleLoginPerformsRedirects(t *testing.T) {
// Performs redirect on state mismatch.
c, close := makeClient(t)
defer close()
c, cleanup := makeClient(t)
defer cleanup()
req := createLoginRequest(t, "state1", "abcd")
......@@ -629,13 +629,13 @@ func TestManageUserInfo(t *testing.T) {
}, nil
}
c, close := makeClientFromConfig(t, &testClientConfig{
c, cleanup := makeClientFromConfig(t, &testClientConfig{
updateIdentityFn: &updateIdentityFn,
introspectOAuth2TokenFn: &introspectOAuth2TokenFn,
getIdentityFn: &getIdentityFn,
})
defer close()
defer cleanup()
_, err := c.UpdateUserInfo(context.Background(), plUserID, &KratosUserInfo{
Email: email,
PLOrgID: plOrgID,
......
......@@ -90,13 +90,13 @@ func (p *ILMPolicy) Rollover(maxSize *string, maxDocs *int, maxAge *string) *ILM
// DeleteAfter adds a delete action to the policy's delete phase.
// This actions causes rolled over indices to be deleted after `timeBeforeDelete` time has passed.
func (p *ILMPolicy) DeleteAfter(timeBeforeDelete string) *ILMPolicy {
delete := p.mapForPhase("delete")
delete["min_age"] = timeBeforeDelete
del := p.mapForPhase("delete")
del["min_age"] = timeBeforeDelete
if delete["actions"] == nil {
delete["actions"] = make(map[string]interface{})
if del["actions"] == nil {
del["actions"] = make(map[string]interface{})
}
actions := delete["actions"].(map[string]interface{})
actions := del["actions"].(map[string]interface{})
actions["delete"] = make(map[string]interface{})
return p
......
......@@ -62,18 +62,18 @@ func TestUInt128FromProto(t *testing.T) {
Low: uint64(456),
}
uint := UInt128FromProto(uintPb)
assert.Equal(t, uint64(123), uint.High)
assert.Equal(t, uint64(456), uint.Low)
uint1 := UInt128FromProto(uintPb)
assert.Equal(t, uint64(123), uint1.High)
assert.Equal(t, uint64(456), uint1.Low)
}
func TestProtoFromUInt128(t *testing.T) {
uint := &UInt128{
uint1 := &UInt128{
High: uint64(123),
Low: uint64(456),
}
uintPb := ProtoFromUInt128(uint)
uintPb := ProtoFromUInt128(uint1)
assert.Equal(t, uint64(123), uintPb.High)
assert.Equal(t, uint64(456), uintPb.Low)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment