[tor-commits] [goptlib/master] Prevent messages from going to stdout in tests.

dcf at torproject.org dcf at torproject.org
Wed Nov 27 06:07:29 UTC 2013


commit c661fbaf9d4e121a26e629cc9e8e6b7a64174129
Author: David Fifield <david at bamsoftware.com>
Date:   Mon Nov 25 21:08:09 2013 -0800

    Prevent messages from going to stdout in tests.
    
    We might later want to actually test what these messages look like; we
    can replace Stdout with e.g. a bytes.Buffer to do that.
---
 pt_test.go |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pt_test.go b/pt_test.go
index ee471fa..979dd56 100644
--- a/pt_test.go
+++ b/pt_test.go
@@ -2,6 +2,7 @@ package pt
 
 import (
 	"bytes"
+	"io/ioutil"
 	"net"
 	"os"
 	"sort"
@@ -59,6 +60,8 @@ func TestGetManagedTransportVer(t *testing.T) {
 		{"2,1", "1"},
 	}
 
+	Stdout = ioutil.Discard
+
 	os.Clearenv()
 	_, err := getManagedTransportVer()
 	if err == nil {
@@ -159,6 +162,8 @@ func TestGetClientTransports(t *testing.T) {
 		},
 	}
 
+	Stdout = ioutil.Discard
+
 	os.Clearenv()
 	_, err := getClientTransports([]string{"alpha", "beta", "gamma"})
 	if err == nil {
@@ -299,6 +304,8 @@ func TestGetServerBindaddrs(t *testing.T) {
 		},
 	}
 
+	Stdout = ioutil.Discard
+
 	os.Clearenv()
 	_, err := getServerBindaddrs([]string{"alpha", "beta", "gamma"})
 	if err == nil {





More information about the tor-commits mailing list