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

Delta Between Two Patch Sets: cmd/jujud/unit_test.go

Issue 6501106: environs: remove VarDir global
Left Patch Set: environs: remove VarDir global Created 11 years, 6 months ago
Right Patch Set: environs: remove VarDir global Created 11 years, 6 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:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/jujud/unit.go ('k') | cmd/jujud/upgrade.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package main 1 package main
2 2
3 import ( 3 import (
4 "io/ioutil" 4 "io/ioutil"
5 . "launchpad.net/gocheck" 5 . "launchpad.net/gocheck"
6 "launchpad.net/juju-core/cmd" 6 "launchpad.net/juju-core/cmd"
7 "launchpad.net/juju-core/environs"
8 "launchpad.net/juju-core/juju/testing" 7 "launchpad.net/juju-core/juju/testing"
9 "launchpad.net/juju-core/state" 8 "launchpad.net/juju-core/state"
10 "launchpad.net/juju-core/version" 9 "launchpad.net/juju-core/version"
11 "os" 10 "os"
12 "path/filepath" 11 "path/filepath"
13 "time" 12 "time"
14 ) 13 )
15 14
16 type UnitSuite struct { 15 type UnitSuite struct {
17 testing.JujuConnSuite 16 testing.JujuConnSuite
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 54
56 func (s *UnitSuite) TestRunStop(c *C) { 55 func (s *UnitSuite) TestRunStop(c *C) {
57 // Set up state. 56 // Set up state.
58 ch := s.AddTestingCharm(c, "dummy") 57 ch := s.AddTestingCharm(c, "dummy")
59 svc, err := s.Conn.AddService("dummy", ch) 58 svc, err := s.Conn.AddService("dummy", ch)
60 c.Assert(err, IsNil) 59 c.Assert(err, IsNil)
61 unit, err := svc.AddUnit() 60 unit, err := svc.AddUnit()
62 c.Assert(err, IsNil) 61 c.Assert(err, IsNil)
63 62
64 // Set up local environment. 63 // Set up local environment.
65 » jujuDir := environs.VarDir 64 » dataDir := s.DataDir()
66 vers := version.Current.String() 65 vers := version.Current.String()
67 » toolsDir := filepath.Join(jujuDir, "tools", vers) 66 » toolsDir := filepath.Join(dataDir, "tools", vers)
68 err = os.MkdirAll(toolsDir, 0755) 67 err = os.MkdirAll(toolsDir, 0755)
69 c.Assert(err, IsNil) 68 c.Assert(err, IsNil)
70 err = ioutil.WriteFile(filepath.Join(toolsDir, "jujuc"), nil, 0644) 69 err = ioutil.WriteFile(filepath.Join(toolsDir, "jujuc"), nil, 0644)
71 c.Assert(err, IsNil) 70 c.Assert(err, IsNil)
72 » toolsLink := filepath.Join(jujuDir, "tools", "unit-dummy-0") 71 » toolsLink := filepath.Join(dataDir, "tools", "unit-dummy-0")
73 err = os.Symlink(vers, toolsLink) 72 err = os.Symlink(vers, toolsLink)
74 c.Assert(err, IsNil) 73 c.Assert(err, IsNil)
75 74
76 // Run a unit agent. 75 // Run a unit agent.
77 a := &UnitAgent{ 76 a := &UnitAgent{
78 » » Conf: AgentConf{jujuDir, *s.StateInfo(c)}, 77 » » Conf: AgentConf{dataDir, *s.StateInfo(c)},
79 UnitName: unit.Name(), 78 UnitName: unit.Name(),
80 } 79 }
81 done := make(chan error) 80 done := make(chan error)
82 go func() { 81 go func() {
83 done <- a.Run(nil) 82 done <- a.Run(nil)
84 }() 83 }()
85 defer a.Stop() 84 defer a.Stop()
86 timeout := time.After(3 * time.Second) 85 timeout := time.After(3 * time.Second)
87 for { 86 for {
88 select { 87 select {
(...skipping 11 matching lines...) Expand all
100 default: 99 default:
101 c.Fatalf("unexpected status %s %s", st, info) 100 c.Fatalf("unexpected status %s %s", st, info)
102 } 101 }
103 } 102 }
104 break 103 break
105 } 104 }
106 err = a.Stop() 105 err = a.Stop()
107 c.Assert(err, IsNil) 106 c.Assert(err, IsNil)
108 c.Assert(<-done, IsNil) 107 c.Assert(<-done, IsNil)
109 } 108 }
LEFTRIGHT

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