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

Side by Side Diff: juju/testing/conn.go

Issue 6488077: juju: always connect to State.
Patch Set: juju: always connect to State. Created 12 years, 7 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:
View unified diff | Download patch
« no previous file with comments | « juju/deploy_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package testing 1 package testing
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "io/ioutil" 5 "io/ioutil"
6 . "launchpad.net/gocheck" 6 . "launchpad.net/gocheck"
7 "launchpad.net/juju-core/charm" 7 "launchpad.net/juju-core/charm"
8 "launchpad.net/juju-core/environs" 8 "launchpad.net/juju-core/environs"
9 "launchpad.net/juju-core/environs/dummy" 9 "launchpad.net/juju-core/environs/dummy"
10 "launchpad.net/juju-core/juju" 10 "launchpad.net/juju-core/juju"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 varDir := filepath.Join(s.rootDir, environs.VarDir) 85 varDir := filepath.Join(s.rootDir, environs.VarDir)
86 err = os.MkdirAll(varDir, 0777) 86 err = os.MkdirAll(varDir, 0777)
87 c.Assert(err, IsNil) 87 c.Assert(err, IsNil)
88 environs.VarDir = varDir 88 environs.VarDir = varDir
89 89
90 err = os.Mkdir(filepath.Join(home, ".juju"), 0777) 90 err = os.Mkdir(filepath.Join(home, ".juju"), 0777)
91 c.Assert(err, IsNil) 91 c.Assert(err, IsNil)
92 92
93 err = ioutil.WriteFile(filepath.Join(home, ".juju", "environments.yaml") , config, 0600) 93 err = ioutil.WriteFile(filepath.Join(home, ".juju", "environments.yaml") , config, 0600)
94 c.Assert(err, IsNil) 94 c.Assert(err, IsNil)
95 » conn, err := juju.NewConn("dummyenv") 95
96 » environ, err := environs.NewFromName("dummyenv")
96 c.Assert(err, IsNil) 97 c.Assert(err, IsNil)
98 // sanity check we've got the correct environment.
99 c.Assert(environ.Name(), Equals, "dummyenv")
100 c.Assert(environ.Bootstrap(false), IsNil)
97 101
98 » // sanity check we've got the correct environment. 102 » conn, err := juju.NewConnFromName("dummyenv")
99 » c.Assert(conn.Environ.Name(), Equals, "dummyenv") 103 » c.Assert(err, IsNil)
100
101 » c.Assert(conn.Bootstrap(false), IsNil)
102 s.Conn = conn 104 s.Conn = conn
103 » s.State, err = conn.State() 105 » s.State = conn.State
104 c.Assert(err, IsNil) 106 c.Assert(err, IsNil)
105 } 107 }
106 108
107 func (s *JujuConnSuite) tearDownConn(c *C) { 109 func (s *JujuConnSuite) tearDownConn(c *C) {
108 dummy.Reset() 110 dummy.Reset()
109 c.Assert(s.Conn.Close(), IsNil) 111 c.Assert(s.Conn.Close(), IsNil)
110 s.Conn = nil 112 s.Conn = nil
111 s.State = nil 113 s.State = nil
112 os.Setenv("HOME", s.oldHome) 114 os.Setenv("HOME", s.oldHome)
113 s.oldHome = "" 115 s.oldHome = ""
(...skipping 21 matching lines...) Expand all
135 func (s *JujuConnSuite) AddTestingCharm(c *C, name string) *state.Charm { 137 func (s *JujuConnSuite) AddTestingCharm(c *C, name string) *state.Charm {
136 ch := testing.Charms.Dir(name) 138 ch := testing.Charms.Dir(name)
137 ident := fmt.Sprintf("%s-%d", name, ch.Revision()) 139 ident := fmt.Sprintf("%s-%d", name, ch.Revision())
138 curl := charm.MustParseURL("local:series/" + ident) 140 curl := charm.MustParseURL("local:series/" + ident)
139 bundleURL, err := url.Parse("http://bundles.example.com/" + ident) 141 bundleURL, err := url.Parse("http://bundles.example.com/" + ident)
140 c.Assert(err, IsNil) 142 c.Assert(err, IsNil)
141 sch, err := s.State.AddCharm(ch, curl, bundleURL, ident+"-sha256") 143 sch, err := s.State.AddCharm(ch, curl, bundleURL, ident+"-sha256")
142 c.Assert(err, IsNil) 144 c.Assert(err, IsNil)
143 return sch 145 return sch
144 } 146 }
OLDNEW
« no previous file with comments | « juju/deploy_test.go ('k') | no next file » | no next file with comments »

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