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

Delta Between Two Patch Sets: state/api/client_test.go

Issue 58510045: debug-log: added new debug log api and command
Left Patch Set: debug-log: added new debug log api and command Created 11 years, 2 months ago
Right Patch Set: debug-log: added new debug log api and command Created 11 years, 1 month 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:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package api_test 4 package api_test
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 "net"
8 "net/http" 9 "net/http"
9 10
10 gc "launchpad.net/gocheck" 11 gc "launchpad.net/gocheck"
11 12
12 "launchpad.net/juju-core/charm" 13 "launchpad.net/juju-core/charm"
13 jujutesting "launchpad.net/juju-core/juju/testing" 14 jujutesting "launchpad.net/juju-core/juju/testing"
14 "launchpad.net/juju-core/state/api" 15 "launchpad.net/juju-core/state/api"
15 "launchpad.net/juju-core/state/api/params" 16 "launchpad.net/juju-core/state/api/params"
16 "launchpad.net/juju-core/testing" 17 "launchpad.net/juju-core/testing"
17 jc "launchpad.net/juju-core/testing/checkers" 18 jc "launchpad.net/juju-core/testing/checkers"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 c.Assert(savedURL.Revision, gc.Equals, 42) 59 c.Assert(savedURL.Revision, gc.Equals, 42)
59 60
60 // Upload a charm directory again, revision should be bumped. 61 // Upload a charm directory again, revision should be bumped.
61 savedURL, err = client.AddLocalCharm(curl, charmDir) 62 savedURL, err = client.AddLocalCharm(curl, charmDir)
62 c.Assert(err, gc.IsNil) 63 c.Assert(err, gc.IsNil)
63 c.Assert(savedURL.String(), gc.Equals, curl.WithRevision(43).String()) 64 c.Assert(savedURL.String(), gc.Equals, curl.WithRevision(43).String())
64 65
65 // Finally, try the NotImplementedError by mocking the server 66 // Finally, try the NotImplementedError by mocking the server
66 // address to a handler that returns 405 Method Not Allowed for 67 // address to a handler that returns 405 Method Not Allowed for
67 // POST. 68 // POST.
69 lis, err := net.Listen("tcp", ":0")
70 c.Assert(err, gc.IsNil)
71 port := lis.Addr().(*net.TCPAddr).Port
72 url := fmt.Sprintf("localhost:%d", port)
68 http.HandleFunc("/charms", func(w http.ResponseWriter, r *http.Request) { 73 http.HandleFunc("/charms", func(w http.ResponseWriter, r *http.Request) {
69 if r.Method == "POST" { 74 if r.Method == "POST" {
70 http.Error(w, "Method Not Allowed", http.StatusMethodNot Allowed) 75 http.Error(w, "Method Not Allowed", http.StatusMethodNot Allowed)
71 } 76 }
72 }) 77 })
73 go func() { 78 go func() {
74 » » err = http.ListenAndServe(":8900", nil) 79 » » err = http.Serve(lis, nil)
75 c.Assert(err, gc.IsNil) 80 c.Assert(err, gc.IsNil)
76 }() 81 }()
77 82
78 » api.SetServerRoot(client, "http://localhost:8900") 83 » api.SetServerHostPort(client, url)
79 _, err = client.AddLocalCharm(curl, charmArchive) 84 _, err = client.AddLocalCharm(curl, charmArchive)
80 c.Assert(err, jc.Satisfies, params.IsCodeNotImplemented) 85 c.Assert(err, jc.Satisfies, params.IsCodeNotImplemented)
81 } 86 }
LEFTRIGHT

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