Merge lp:~chipaca/ubuntu-push/bushtest into lp:ubuntu-push

Proposed by John Lenton
Status: Work in progress
Proposed branch: lp:~chipaca/ubuntu-push/bushtest
Merge into: lp:ubuntu-push
Prerequisite: lp:~chipaca/ubuntu-push/redialer
Diff against target: 94 lines (+48/-5)
2 files modified
bus/bus_test.go (+1/-1)
bus/endpoint_test.go (+47/-4)
To merge this branch: bzr merge lp:~chipaca/ubuntu-push/bushtest
Reviewer Review Type Date Requested Status
Ubuntu Push Hackers Pending
Review via email: mp+202871@code.launchpad.net

Commit message

Covered a bit of bus with an integration test.

Description of the change

Covered a bit of bus with an integration test.

To post a comment you must log in.
lp:~chipaca/ubuntu-push/bushtest updated
25. By John Lenton

Merged redialer into bushtest.

Revision history for this message
Samuele Pedroni (pedronis) wrote :

tests doing endp.Dial with a real bus should have defer endp.Close()

Revision history for this message
Samuele Pedroni (pedronis) wrote :
Revision history for this message
Samuele Pedroni (pedronis) wrote :

we need to force dbus-launch

or skip if DBUS_SESSION_BUS_ADDRESS is not set or something I think

Revision history for this message
John Lenton (chipaca) wrote :

Shelving this one for now.

Unmerged revisions

25. By John Lenton

Merged redialer into bushtest.

24. By John Lenton

unit tests, schmnit tests. Covered a bit of bus with an integration test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bus/bus_test.go'
2--- bus/bus_test.go 2014-01-24 00:16:46 +0000
3+++ bus/bus_test.go 2014-01-24 00:16:46 +0000
4@@ -26,7 +26,7 @@
5 )
6
7 // hook up gocheck
8-func BusTest(t *testing.T) { TestingT(t) }
9+func TestBus(t *testing.T) { TestingT(t) }
10
11 type BusSuite struct{}
12
13
14=== modified file 'bus/endpoint_test.go'
15--- bus/endpoint_test.go 2014-01-24 00:16:46 +0000
16+++ bus/endpoint_test.go 2014-01-24 00:16:46 +0000
17@@ -23,18 +23,33 @@
18 )
19
20 // hook up gocheck
21-func EndpointTest(t *testing.T) { TestingT(t) }
22+func TestEndpoint(t *testing.T) { TestingT(t) }
23
24 type EndpointSuite struct{}
25
26 var _ = Suite(&EndpointSuite{})
27
28-// TODO: this is going to remain empty until go-dbus grows some
29+// TODO: this is going to remain mostly empty until go-dbus grows some
30 // testing amenities (already talked about it with jamesh)
31
32+// check the string has some info in it
33+func (s *EndpointSuite) TestString(c *C) {
34+ endp := newEndpoint(SystemBus, Address{"foobar", "", ""}, nullog)
35+ c.Assert(endp.String(), Matches, ".*Connection.*Address.*foobar.*")
36+}
37+
38+// ...
39+
40+// OK, ok, so. Integration tests. You need to have a dbus running.
41+// to use a private dbus, run the test with
42+//
43+// DISPLAY= dbus-launch --exit-with-session go test ...
44+//
45+// these don't break anything if you run them on your own bus, though.
46+
47 // Tests that we can connect to the *actual* system bus.
48 // XXX maybe connect to a mock/fake/etc bus?
49-func (s *BusSuite) TestDial(c *C) {
50+func (s *EndpointSuite) TestDial(c *C) {
51 endp := newEndpoint(SystemBus, Address{"", "", ""}, nullog)
52 c.Assert(endp.bus, IsNil)
53 err := endp.Dial()
54@@ -46,7 +61,7 @@
55
56 // Test that if we try to connect to the session bus when no session
57 // bus is available, we get a reasonable result (i.e., an error).
58-func (s *BusSuite) TestDialCanFail(c *C) {
59+func (s *EndpointSuite) TestDialCanFail(c *C) {
60 db := "DBUS_SESSION_BUS_ADDRESS"
61 odb := os.Getenv(db)
62 defer os.Setenv(db, odb)
63@@ -56,3 +71,31 @@
64 err := endp.Dial()
65 c.Check(err, NotNil)
66 }
67+
68+var dbus_addr Address = Address{
69+ "org.freedesktop.DBus",
70+ "/org/freedesktop/DBus",
71+ "org.freedesktop.DBus",
72+}
73+
74+// Test that we can make a call
75+func (s *EndpointSuite) TestCall(c *C) {
76+ endp := newEndpoint(SessionBus, dbus_addr, nullog)
77+ err := endp.Dial()
78+ c.Assert(err, IsNil)
79+ id, err := endp.Call("GetId")
80+ c.Check(err, IsNil)
81+ c.Assert(id, HasLen, 1)
82+ c.Check(id[0].(string), HasLen, 32)
83+}
84+
85+// Test that we can make a rubbish call, too; it'll fail
86+func (s *EndpointSuite) TestCallRubbishFails(c *C) {
87+ endp := newEndpoint(SessionBus, dbus_addr, nullog)
88+ err := endp.Dial()
89+ c.Assert(err, IsNil)
90+ _, err = endp.Call("Rubbish")
91+ c.Check(err, NotNil)
92+}
93+
94+// enough of that for now.

Subscribers

People subscribed via source and target branches