mirror of
https://github.com/coredns/coredns.git
synced 2026-07-21 15:10:18 -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:
@@ -72,11 +72,16 @@ func TestPrint(t *testing.T) {
|
||||
|
||||
f, err := os.CreateTemp(t.TempDir(), "print_test_tmp")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(f.Name())
|
||||
//Redirect the printed results to a tmp file for later comparison
|
||||
// Redirect Print output to a temp file, then restore stdout and close
|
||||
// the handle so TempDir cleanup can remove it on Windows.
|
||||
stdout := os.Stdout
|
||||
os.Stdout = f
|
||||
t.Cleanup(func() {
|
||||
os.Stdout = stdout
|
||||
f.Close()
|
||||
})
|
||||
|
||||
tree.Print()
|
||||
/**
|
||||
@@ -85,12 +90,12 @@ func TestPrint(t *testing.T) {
|
||||
server3.example.com.
|
||||
*/
|
||||
|
||||
if _, err := f.Seek(0, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
buf := make([]byte, 256)
|
||||
f.Seek(0, 0)
|
||||
_, err = f.Read(buf)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
t.Error(err)
|
||||
if _, err := f.Read(buf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
height := strings.Count(string(buf), ". \n")
|
||||
//Compare the height of the print with the actual height of the tree
|
||||
|
||||
Reference in New Issue
Block a user