github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/jujud/reboot/reboot_windows_test.go (about)

     1  package reboot_test
     2  
     3  import (
     4  	"github.com/juju/testing"
     5  	jc "github.com/juju/testing/checkers"
     6  	gc "gopkg.in/check.v1"
     7  
     8  	"github.com/juju/juju/apiserver/params"
     9  	"github.com/juju/juju/cmd/jujud/reboot"
    10  )
    11  
    12  const (
    13  	rebootBin  = "shutdown.exe"
    14  	rebootTime = "15"
    15  )
    16  
    17  func (s *RebootSuite) rebootCommandParams(c *gc.C) []string {
    18  	return []string{
    19  		"-f",
    20  		"-r",
    21  		"-t",
    22  		rebootTime,
    23  	}
    24  }
    25  
    26  func (s *RebootSuite) shutdownCommandParams(c *gc.C) []string {
    27  	return []string{
    28  		"-f",
    29  		"-s",
    30  		"-t",
    31  		rebootTime,
    32  	}
    33  }
    34  
    35  func (s *RebootSuite) TestRebootNoContainers(c *gc.C) {
    36  	w, err := reboot.NewRebootWaiter(s.st, s.acfg)
    37  	c.Assert(err, jc.ErrorIsNil)
    38  	expectedRebootParams := s.rebootCommandParams(c)
    39  
    40  	err = w.ExecuteReboot(params.ShouldReboot)
    41  	c.Assert(err, jc.ErrorIsNil)
    42  	testing.AssertEchoArgs(c, rebootBin, expectedRebootParams...)
    43  }
    44  
    45  func (s *RebootSuite) TestShutdownNoContainers(c *gc.C) {
    46  	w, err := reboot.NewRebootWaiter(s.st, s.acfg)
    47  	c.Assert(err, jc.ErrorIsNil)
    48  	expectedShutdownParams := s.shutdownCommandParams(c)
    49  
    50  	err = w.ExecuteReboot(params.ShouldShutdown)
    51  	c.Assert(err, jc.ErrorIsNil)
    52  	testing.AssertEchoArgs(c, rebootBin, expectedShutdownParams...)
    53  }