~samwhited/xmpp

xmpp/muc/options_test.go -rw-r--r-- 2.5 KiB
c9743d9fSam Whited docs: update changelog to include deprecations 4 days 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Copyright 2021 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 muc

import (
	"testing"
	"time"

	"mellium.im/xmpp/internal/xmpptest"
)

var marshalTestCases = []xmpptest.EncodingTestCase{
	0: {
		Value: func() *config {
			c := &config{}
			MaxHistory(1)(c)
			MaxBytes(2)(c)
			Duration(3 * time.Second)(c)
			Since(time.Time{})(c)
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="1" maxchars="2" seconds="3" since="0001-01-01T00:00:00Z"></history><password>test</password></x>`,
	},
	1: {
		Value: func() *config {
			c := &config{}
			MaxHistory(1)(c)
			MaxBytes(2)(c)
			Duration(3 * time.Second)(c)
			Since(time.Time{})(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="1" maxchars="2" seconds="3" since="0001-01-01T00:00:00Z"></history></x>`,
	},
	2: {
		Value: func() *config {
			c := &config{}
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><password>test</password></x>`,
	},
	3: {
		Value: &config{},
		XML:   `<x xmlns="http://jabber.org/protocol/muc"></x>`,
	},
	4: {
		Value: func() *config {
			c := &config{}
			MaxBytes(2)(c)
			Duration(3 * time.Second)(c)
			Since(time.Time{})(c)
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxchars="2" seconds="3" since="0001-01-01T00:00:00Z"></history><password>test</password></x>`,
	},
	5: {
		Value: func() *config {
			c := &config{}
			MaxHistory(1)(c)
			Duration(3 * time.Second)(c)
			Since(time.Time{})(c)
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="1" seconds="3" since="0001-01-01T00:00:00Z"></history><password>test</password></x>`,
	},
	6: {
		Value: func() *config {
			c := &config{}
			MaxHistory(1)(c)
			MaxBytes(2)(c)
			Since(time.Time{})(c)
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="1" maxchars="2" since="0001-01-01T00:00:00Z"></history><password>test</password></x>`,
	},
	7: {
		Value: func() *config {
			c := &config{}
			MaxHistory(1)(c)
			MaxBytes(2)(c)
			Duration(3 * time.Second)(c)
			Password("test")(c)
			return c
		}(),
		XML: `<x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="1" maxchars="2" seconds="3"></history><password>test</password></x>`,
	},
}

func TestEncode(t *testing.T) {
	xmpptest.RunEncodingTests(t, marshalTestCases)
}