Merge lp:~jtv/gwacl/dispatcher-fixture into lp:gwacl

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: 63
Merged at revision: 64
Proposed branch: lp:~jtv/gwacl/dispatcher-fixture
Merge into: lp:gwacl
Diff against target: 65 lines (+23/-13)
2 files modified
managementapi_test.go (+1/-1)
x509session_test.go (+22/-12)
To merge this branch: bzr merge lp:~jtv/gwacl/dispatcher-fixture
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+155408@code.launchpad.net

Commit message

Extract x509DispatcherFixture from X509SessionSuite, so we don't re-run the session tests wherever we use the fixture.

Description of the change

The management-API test suite embeds the x509 session test suite. This is a bit silly, in that now the x509 session tests get run both as a stand-alone test suite *and* when the management-API tests are run. I noticed this when I got double failures.

The purpose of the duplication was reuse of the facility for injecting test doubles into the x509 dispatcher. This is really a test fixture, so I extracted one.

Jeroen

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Attempt to merge into lp:gwacl failed due to conflicts:

text conflict in managementapi_test.go

Revision history for this message
Julian Edwards (julian-edwards) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

Attempt to merge into lp:gwacl failed due to conflicts:

text conflict in x509session_test.go

lp:~jtv/gwacl/dispatcher-fixture updated
63. By Jeroen T. Vermeulen

Merge trunk, resolve conflict.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'managementapi_test.go'
2--- managementapi_test.go 2013-03-26 08:52:35 +0000
3+++ managementapi_test.go 2013-03-26 09:56:22 +0000
4@@ -9,7 +9,7 @@
5 )
6
7 type managementAPISuite struct {
8- X509SessionSuite
9+ x509DispatcherFixture
10 }
11
12 var _ = Suite(&managementAPISuite{})
13
14=== modified file 'x509session_test.go'
15--- x509session_test.go 2013-03-26 06:50:50 +0000
16+++ x509session_test.go 2013-03-26 09:56:22 +0000
17@@ -17,8 +17,29 @@
18 "time"
19 )
20
21+// x509DispatcherFixture records the current x509 dispatcher before a test,
22+// and restores it after. This gives your test the freedom to replace the
23+// dispatcher with test doubles, using any of the rig*Dispatcher functions.
24+// Call the fixture's SetUpTest/TearDownTest methods before/after your test,
25+// or if you have no other setup/teardown methods, just embed the fixture in
26+// your test suite.
27+type x509DispatcherFixture struct {
28+ oldDispatcher func(*x509Session, *x509Request) (*x509Response, error)
29+}
30+
31+func (suite *x509DispatcherFixture) SetUpTest(c *C) {
32+ // Record the original X509 dispatcher. Will be restored at the end of
33+ // each test.
34+ suite.oldDispatcher = _X509Dispatcher
35+}
36+
37+func (suite *x509DispatcherFixture) TearDownTest(c *C) {
38+ // Restore old dispatcher.
39+ _X509Dispatcher = suite.oldDispatcher
40+}
41+
42 type X509SessionSuite struct {
43- oldDispatcher func(*x509Session, *x509Request) (*x509Response, error)
44+ x509DispatcherFixture
45 }
46
47 var _ = Suite(&X509SessionSuite{})
48@@ -53,17 +74,6 @@
49 }
50 }
51
52-func (suite *X509SessionSuite) SetUpTest(c *C) {
53- // Record the original X509 dispatcher. Will be restored at the end of
54- // each test.
55- suite.oldDispatcher = _X509Dispatcher
56-}
57-
58-func (suite *X509SessionSuite) TearDownTest(c *C) {
59- // Restore old dispatcher.
60- _X509Dispatcher = suite.oldDispatcher
61-}
62-
63 // Create a cert and pem file in a temporary dir in /tmp and return the
64 // names of the files. The caller is responsible for cleaning up the files.
65 func makeX509Certificate() (string, string) {

Subscribers

People subscribed via source and target branches