Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming authored and jsouthworth committed Mar 23, 2021
1 parent 6f46e0d commit c88335c
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,43 @@ import (
)

func TestSessionBus(t *testing.T) {
_, err := SessionBus()
oldConn, err := SessionBus()
if err != nil {
t.Error(err)
}
if err = oldConn.Close(); err != nil {
t.Fatal(err)
}
if oldConn.Connected() {
t.Fatal("Should be closed")
}
newConn, err := SessionBus()
if err != nil {
t.Error(err)
}
if newConn == oldConn {
t.Fatal("Should get a new connection")
}
}

func TestSystemBus(t *testing.T) {
_, err := SystemBus()
oldConn, err := SystemBus()
if err != nil {
t.Error(err)
}
if err = oldConn.Close(); err != nil {
t.Fatal(err)
}
if oldConn.Connected() {
t.Fatal("Should be closed")
}
newConn, err := SystemBus()
if err != nil {
t.Error(err)
}
if newConn == oldConn {
t.Fatal("Should get a new connection")
}
}

func TestConnectSessionBus(t *testing.T) {
Expand All @@ -34,6 +60,9 @@ func TestConnectSessionBus(t *testing.T) {
if err = conn.Close(); err != nil {
t.Fatal(err)
}
if conn.Connected() {
t.Fatal("Should be closed")
}
}

func TestConnectSystemBus(t *testing.T) {
Expand All @@ -44,6 +73,9 @@ func TestConnectSystemBus(t *testing.T) {
if err = conn.Close(); err != nil {
t.Fatal(err)
}
if conn.Connected() {
t.Fatal("Should be closed")
}
}

func TestSend(t *testing.T) {
Expand Down

0 comments on commit c88335c

Please sign in to comment.