mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
fix(plugin): nilness findings (#7556)
Enable nilness linter in govet. Plugin-by-plugin rationale: - plugin/transfer: reuse error instead of shadowing it inside the for loop by declaring "ret" outside of the loop - plugin/view: remove redundant err check - plugin/dnstap: avoid possible nil dereference in error reporting path in setup test - plugin/forward: prevent nil deference or empty-slice dereference on error paths in setup test Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -112,7 +112,6 @@ func TestSetupTLS(t *testing.T) {
|
||||
for i, test := range tests {
|
||||
c := caddy.NewTestController("dns", test.input)
|
||||
fs, err := parseForward(c)
|
||||
f := fs[0]
|
||||
|
||||
if test.shouldErr && err == nil {
|
||||
t.Errorf("Test %d: expected error but found %s for input %s", i, err, test.input)
|
||||
@@ -128,6 +127,8 @@ func TestSetupTLS(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
f := fs[0]
|
||||
|
||||
if !test.shouldErr && test.expectedServerName != "" && test.expectedServerName != f.tlsConfig.ServerName {
|
||||
t.Errorf("Test %d: expected: %q, actual: %q", i, test.expectedServerName, f.tlsConfig.ServerName)
|
||||
}
|
||||
@@ -314,7 +315,7 @@ func TestMultiForward(t *testing.T) {
|
||||
handlers := dnsserver.GetConfig(c).Handlers()
|
||||
f1, ok := handlers[0].(*Forward)
|
||||
if !ok {
|
||||
t.Fatalf("expected first plugin to be Forward, got %v", reflect.TypeOf(f1.Next))
|
||||
t.Fatalf("expected first plugin to be Forward, got %v", reflect.TypeOf(handlers[0]))
|
||||
}
|
||||
|
||||
if f1.from != "1st.example.org." {
|
||||
|
||||
Reference in New Issue
Block a user