コード例 #1
0
ファイル: mock.go プロジェクト: kaihendry/go-imap
// Dial returns a new Client connected to the scripted server or an error if the
// connection could not be established.
func (t *T) Dial() (*imap.Client, error) {
	cn := t.cn
	if t.cn = nil; cn == nil {
		t.Fatalf(cl("t.Dial() or t.DialTLS() already called for this server"))
	}
	var err error
	if t.c, err = imap.NewClient(cn, ServerName, Timeout); err != nil {
		cn.Close()
	}
	return t.c, err
}
コード例 #2
0
ファイル: mock.go プロジェクト: kaihendry/go-imap
// DialTLS returns a new Client connected to the scripted server or an error if
// the connection could not be established. The server is expected to negotiate
// encryption before sending the initial greeting. Config should be nil when
// used in combination with the predefined STARTTLS script action.
func (t *T) DialTLS(config *tls.Config) (*imap.Client, error) {
	cn := t.cn
	if t.cn = nil; cn == nil {
		t.Fatalf(cl("t.Dial() or t.DialTLS() already called for this server"))
	}
	if config == nil {
		config = clientTLS()
	}
	tlsConn := tls.Client(cn, config)
	var err error
	if t.c, err = imap.NewClient(tlsConn, ServerName, Timeout); err != nil {
		cn.Close()
	}
	return t.c, err
}