aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/smtp
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-01-02 15:05:27 -0800
committerIan Lance Taylor <iant@golang.org>2020-01-21 23:53:22 -0800
commit5a8ea165926cb0737ab03bc48c18dc5198ab5305 (patch)
tree962dc3357c57f019f85658f99e2e753e30201c27 /libgo/go/net/smtp
parent6ac6529e155c9baa0aaaed7aca06bd38ebda5b43 (diff)
downloadgcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.zip
gcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.tar.gz
gcc-5a8ea165926cb0737ab03bc48c18dc5198ab5305.tar.bz2
libgo: update to Go1.14beta1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214297
Diffstat (limited to 'libgo/go/net/smtp')
-rw-r--r--libgo/go/net/smtp/smtp_test.go34
1 files changed, 22 insertions, 12 deletions
diff --git a/libgo/go/net/smtp/smtp_test.go b/libgo/go/net/smtp/smtp_test.go
index 8195f91..cfda079 100644
--- a/libgo/go/net/smtp/smtp_test.go
+++ b/libgo/go/net/smtp/smtp_test.go
@@ -9,13 +9,13 @@ import (
"bytes"
"crypto/tls"
"crypto/x509"
+ "fmt"
"internal/testenv"
"io"
"net"
"net/textproto"
"runtime"
"strings"
- "sync"
"testing"
"time"
)
@@ -642,13 +642,13 @@ func TestSendMailWithAuth(t *testing.T) {
t.Fatalf("Unable to create listener: %v", err)
}
defer l.Close()
- wg := sync.WaitGroup{}
- var done = make(chan struct{})
+
+ errCh := make(chan error)
go func() {
- defer wg.Done()
+ defer close(errCh)
conn, err := l.Accept()
if err != nil {
- t.Errorf("Accept error: %v", err)
+ errCh <- fmt.Errorf("Accept: %v", err)
return
}
defer conn.Close()
@@ -656,13 +656,21 @@ func TestSendMailWithAuth(t *testing.T) {
tc := textproto.NewConn(conn)
tc.PrintfLine("220 hello world")
msg, err := tc.ReadLine()
- if msg == "EHLO localhost" {
- tc.PrintfLine("250 mx.google.com at your service")
+ if err != nil {
+ errCh <- fmt.Errorf("ReadLine error: %v", err)
+ return
+ }
+ const wantMsg = "EHLO localhost"
+ if msg != wantMsg {
+ errCh <- fmt.Errorf("unexpected response %q; want %q", msg, wantMsg)
+ return
+ }
+ err = tc.PrintfLine("250 mx.google.com at your service")
+ if err != nil {
+ errCh <- fmt.Errorf("PrintfLine: %v", err)
+ return
}
- // for this test case, there should have no more traffic
- <-done
}()
- wg.Add(1)
err = SendMail(l.Addr().String(), PlainAuth("", "user", "pass", "smtp.google.com"), "test@example.com", []string{"other@example.com"}, []byte(strings.Replace(`From: test@example.com
To: other@example.com
@@ -676,8 +684,10 @@ SendMail is working for me.
if err.Error() != "smtp: server doesn't support AUTH" {
t.Errorf("Expected: smtp: server doesn't support AUTH, got: %s", err)
}
- close(done)
- wg.Wait()
+ err = <-errCh
+ if err != nil {
+ t.Fatalf("server error: %v", err)
+ }
}
func TestAuthFailed(t *testing.T) {