github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/cloudinit/progress_test.go (about)

     1  // Copyright 2011, 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package cloudinit_test
     5  
     6  import (
     7  	"regexp"
     8  
     9  	gc "gopkg.in/check.v1"
    10  
    11  	"github.com/juju/juju/cloudinit"
    12  )
    13  
    14  type progressSuite struct{}
    15  
    16  var _ = gc.Suite(&progressSuite{})
    17  
    18  func (*progressSuite) TestProgressCmds(c *gc.C) {
    19  	initCmd := cloudinit.InitProgressCmd()
    20  	re := regexp.MustCompile(`test -e /proc/self/fd/([0-9]+) \|\| exec ([0-9]+)>&2`)
    21  	submatch := re.FindStringSubmatch(initCmd)
    22  	c.Assert(submatch, gc.HasLen, 3)
    23  	c.Assert(submatch[0], gc.Equals, initCmd)
    24  	c.Assert(submatch[1], gc.Equals, submatch[2])
    25  	logCmd := cloudinit.LogProgressCmd("he'llo\"!")
    26  	c.Assert(logCmd, gc.Equals, `echo 'he'"'"'llo"!' >&`+submatch[1])
    27  }