Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Delta Between Two Patch Sets: suite_test.go

Issue 5433056: Add ec2test package for fake EC2 server.
Left Patch Set: Created 13 years, 4 months ago
Right Patch Set: - Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sign_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package ec2_test 1 package ec2_test
2 2
3 import ( 3 import (
4 "flag"
4 "fmt" 5 "fmt"
6 "launchpad.net/goamz/aws"
5 . "launchpad.net/gocheck" 7 . "launchpad.net/gocheck"
6 "net/http" 8 "net/http"
7 "net/url" 9 "net/url"
8 "os" 10 "os"
9 "testing" 11 "testing"
10 "time" 12 "time"
11 ) 13 )
12 14
13 func Test(t *testing.T) { 15 func Test(t *testing.T) {
14 TestingT(t) 16 TestingT(t)
17 }
18
19 var integration = flag.Bool("i", false, "Enable integration tests")
20
21 type SuiteI struct {
22 auth aws.Auth
23 }
24
25 func (s *SuiteI) SetUpSuite(c *C) {
26 if !*integration {
27 c.Skip("Integration tests not enabled (-i flag)")
28 }
29 auth, err := aws.EnvAuth()
30 if err != nil {
31 c.Fatal(err.Error())
32 }
33 s.auth = auth
34 }
35
36 type HTTPSuite struct{}
37
38 var testServer = NewTestHTTPServer("http://localhost:4444", 5e9)
39
40 func (s *HTTPSuite) SetUpSuite(c *C) {
41 testServer.Start()
42 }
43
44 func (s *HTTPSuite) TearDownTest(c *C) {
45 testServer.FlushRequests()
15 } 46 }
16 47
17 type TestHTTPServer struct { 48 type TestHTTPServer struct {
18 URL string 49 URL string
19 Timeout int64 50 Timeout int64
20 started bool 51 started bool
21 request chan *http.Request 52 request chan *http.Request
22 response chan *testResponse 53 response chan *testResponse
23 pending chan bool 54 pending chan bool
24 } 55 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return req 130 return req
100 case <-time.After(s.Timeout): 131 case <-time.After(s.Timeout):
101 panic("Timeout waiting for goamz request") 132 panic("Timeout waiting for goamz request")
102 } 133 }
103 panic("unreached") 134 panic("unreached")
104 } 135 }
105 136
106 func (s *TestHTTPServer) PrepareResponse(status int, headers map[string]string, body string) { 137 func (s *TestHTTPServer) PrepareResponse(status int, headers map[string]string, body string) {
107 s.response <- &testResponse{status, headers, body} 138 s.response <- &testResponse{status, headers, body}
108 } 139 }
LEFTRIGHT
« sign_test.go ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b