Skip to content

Commit 0130415

Browse files
Fix password change tests
1 parent 75c3388 commit 0130415

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

service/windows/password_windows_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type myAmazingServiceManager struct {
2929
func (mgr *myAmazingServiceManager) ChangeServicePassword(name, newPassword string) error {
3030
mgr.svcNames = append(mgr.svcNames, name)
3131
mgr.pwd = newPassword
32-
if name == "failme" {
32+
if name == "jujud-unit-failme" {
3333
return errors.New("wubwub")
3434
}
3535
return nil
@@ -48,11 +48,12 @@ func (s *ServicePasswordChangerSuite) SetUpTest(c *gc.C) {
4848
}
4949

5050
func listServices() ([]string, error) {
51-
return []string{"boom", "pow"}, nil
51+
// all services except those prefixed with jujud-unit will be filtered out.
52+
return []string{"boom", "pow", "jujud-unit-valid", "jujud-unit-another"}, nil
5253
}
5354

5455
func listServicesFailingService() ([]string, error) {
55-
return []string{"boom", "failme", "pow"}, nil
56+
return []string{"boom", "pow", "jujud-unit-failme"}, nil
5657
}
5758

5859
func brokenListServices() ([]string, error) {
@@ -62,7 +63,7 @@ func brokenListServices() ([]string, error) {
6263
func (s *ServicePasswordChangerSuite) TestChangeServicePasswordListSucceeds(c *gc.C) {
6364
err := s.c.ChangeJujudServicesPassword("newPass", s.mgr, listServices)
6465
c.Assert(err, jc.ErrorIsNil)
65-
c.Assert(s.mgr.svcNames, gc.DeepEquals, []string{"boom", "pow"})
66+
c.Assert(s.mgr.svcNames, gc.DeepEquals, []string{"jujud-unit-valid", "jujud-unit-another"})
6667
c.Assert(s.mgr.pwd, gc.Equals, "newPass")
6768
}
6869

@@ -74,7 +75,7 @@ func (s *ServicePasswordChangerSuite) TestChangeServicePasswordListFails(c *gc.C
7475
func (s *ServicePasswordChangerSuite) TestChangePasswordFails(c *gc.C) {
7576
err := s.c.ChangeJujudServicesPassword("newPass", s.mgr, listServicesFailingService)
7677
c.Assert(err, gc.ErrorMatches, "wubwub")
77-
c.Assert(s.mgr.svcNames, gc.DeepEquals, []string{"boom", "failme"})
78+
c.Assert(s.mgr.svcNames, gc.DeepEquals, []string{"jujud-unit-failme"})
7879
c.Assert(s.mgr.pwd, gc.Equals, "newPass")
7980
}
8081

service/windows/service_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package windows_test
66

77
import (
8+
"fmt"
9+
810
"github.com/juju/errors"
911
"github.com/juju/testing"
1012
jc "github.com/juju/testing/checkers"
@@ -212,9 +214,9 @@ func (s *serviceSuite) TestInstallCommands(c *gc.C) {
212214
c.Assert(err, gc.IsNil)
213215

214216
expected := []string{
215-
fmt.Sprintf("New-Service -Name %s -DependsOn Winmgmt -DisplayName %s %s", s.name, s.conf.Desc, s.conf.ExecStart),
216-
fmt.Sprintf("sc.exe failure %s reset=5 actions=restart/1000", s.name),
217-
fmt.Sprintf("sc.exe failureflag %s 1", s.name),
217+
fmt.Sprintf("New-Service -Name '%s' -DependsOn Winmgmt -DisplayName '%s' '%s'", s.name, s.conf.Desc, s.conf.ExecStart),
218+
fmt.Sprintf("sc.exe failure '%s' reset=5 actions=restart/1000", s.name),
219+
fmt.Sprintf("sc.exe failureflag '%s' 1", s.name),
218220
}
219221

220222
c.Assert(commands, gc.DeepEquals, expected)

0 commit comments

Comments
 (0)