@@ -13,17 +13,43 @@ import (
13
13
)
14
14
15
15
func TestSessionBus (t * testing.T ) {
16
- _ , err := SessionBus ()
16
+ oldConn , err := SessionBus ()
17
17
if err != nil {
18
18
t .Error (err )
19
19
}
20
+ if err = oldConn .Close (); err != nil {
21
+ t .Fatal (err )
22
+ }
23
+ if oldConn .Connected () {
24
+ t .Fatal ("Should be closed" )
25
+ }
26
+ newConn , err := SessionBus ()
27
+ if err != nil {
28
+ t .Error (err )
29
+ }
30
+ if newConn == oldConn {
31
+ t .Fatal ("Should get a new connection" )
32
+ }
20
33
}
21
34
22
35
func TestSystemBus (t * testing.T ) {
23
- _ , err := SystemBus ()
36
+ oldConn , err := SystemBus ()
37
+ if err != nil {
38
+ t .Error (err )
39
+ }
40
+ if err = oldConn .Close (); err != nil {
41
+ t .Fatal (err )
42
+ }
43
+ if oldConn .Connected () {
44
+ t .Fatal ("Should be closed" )
45
+ }
46
+ newConn , err := SystemBus ()
24
47
if err != nil {
25
48
t .Error (err )
26
49
}
50
+ if newConn == oldConn {
51
+ t .Fatal ("Should get a new connection" )
52
+ }
27
53
}
28
54
29
55
func TestConnectSessionBus (t * testing.T ) {
@@ -34,6 +60,9 @@ func TestConnectSessionBus(t *testing.T) {
34
60
if err = conn .Close (); err != nil {
35
61
t .Fatal (err )
36
62
}
63
+ if conn .Connected () {
64
+ t .Fatal ("Should be closed" )
65
+ }
37
66
}
38
67
39
68
func TestConnectSystemBus (t * testing.T ) {
@@ -44,6 +73,9 @@ func TestConnectSystemBus(t *testing.T) {
44
73
if err = conn .Close (); err != nil {
45
74
t .Fatal (err )
46
75
}
76
+ if conn .Connected () {
77
+ t .Fatal ("Should be closed" )
78
+ }
47
79
}
48
80
49
81
func TestSend (t * testing.T ) {
0 commit comments