~samwhited/xmpp

ref: 379c0dc11b58c2a0b146bf34557e6e5360bd592f xmpp/dial_test.go -rw-r--r-- 938 bytes
379c0dc1Sam Whited styling: remove styling experiment 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2016 The Mellium Contributors.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package xmpp

import (
	"testing"

	"mellium.im/xmpp/jid"
)

func TestDialClientPanicsIfNilContext(t *testing.T) {
	defer func() {
		if r := recover(); r == nil {
			t.Error("Expected Dial to panic when passed a nil context.")
		}
	}()
	DialClient(nil, "tcp", jid.MustParse("feste@shakespeare.lit"))
}

// The default value of config.conntype should return "xmpp-client"
func TestDefaultConnType(t *testing.T) {
	if ct := connType(false); ct != "xmpp-client" {
		t.Errorf("Wrong default value for conntype; expected xmpp-client but got %s", ct)
	}
}

// If S2S is true, config.conntype should return "xmpp-server"
func TestS2SConnType(t *testing.T) {
	if ct := connType(true); ct != "xmpp-server" {
		t.Errorf("Wrong s2s value for conntype; expected xmpp-server but got %s", ct)
	}
}