mirror of
https://github.com/coredns/coredns.git
synced 2026-07-22 07:30:13 -04:00
ci: run plugin tests on Windows (#8314)
Plugin package tests previously ran only on Linux, so Windows- specific failures were never caught. Run them in CI and make the affected tests portable across platforms. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -2,6 +2,7 @@ package tls
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -52,6 +53,12 @@ func TestTLS(t *testing.T) {
|
||||
t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input)
|
||||
}
|
||||
}
|
||||
|
||||
// setup registers OnShutdown to close KeyLogWriter, but tests never shut down.
|
||||
// Close explicitly so t.TempDir cleanup can remove the file on Windows.
|
||||
if err == nil {
|
||||
closeKeyLogWriter(t, dnsserver.GetConfig(c))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,5 +128,22 @@ func TestTLSKeyLog(t *testing.T) {
|
||||
if cfg.TLSConfig.KeyLogWriter == nil {
|
||||
t.Fatal("KeyLogWriter is not set")
|
||||
}
|
||||
// setup registers OnShutdown to close KeyLogWriter, but tests never shut down.
|
||||
// Close explicitly so t.TempDir cleanup can remove the file on Windows.
|
||||
closeKeyLogWriter(t, cfg)
|
||||
})
|
||||
}
|
||||
|
||||
func closeKeyLogWriter(t *testing.T, cfg *dnsserver.Config) {
|
||||
t.Helper()
|
||||
if cfg.TLSConfig == nil {
|
||||
return
|
||||
}
|
||||
closer, ok := cfg.TLSConfig.KeyLogWriter.(io.Closer)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
closer.Close()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user