github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/worker/uniter/runner/jujuc/credential-get_test.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package jujuc_test
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"github.com/juju/cmd/cmdtesting"
     9  	jc "github.com/juju/testing/checkers"
    10  	gc "gopkg.in/check.v1"
    11  
    12  	"github.com/juju/juju/worker/uniter/runner/jujuc"
    13  )
    14  
    15  type CredentialGetSuite struct {
    16  	ContextSuite
    17  }
    18  
    19  var _ = gc.Suite(&CredentialGetSuite{})
    20  
    21  // [TODO](externalreality): Many jujuc commands can be run through a processor
    22  // much like the one below. This sort of thing should not have to be written
    23  // more than once except for in special cases. A structure containing all of the
    24  // relevant jujuc commands along with their supported format options would cut
    25  // down on a great deal of test fluff. The juju/cmd test are a good example of how
    26  // this might be done.
    27  func runCredentialGetCommand(s *CredentialGetSuite, c *gc.C, args []string) (*cmd.Context, int) {
    28  	hctx := s.GetHookContext(c, -1, "")
    29  	com, err := jujuc.NewCommand(hctx, cmdString("credential-get"))
    30  	c.Assert(err, jc.ErrorIsNil)
    31  	ctx := cmdtesting.Context(c)
    32  	code := cmd.Main(jujuc.NewJujucCommandWrappedForTest(com), ctx, args)
    33  	return ctx, code
    34  }
    35  
    36  func (s *CredentialGetSuite) TestCommandRun(c *gc.C) {
    37  	_, exitCode := runCredentialGetCommand(s, c, []string{})
    38  	exitSuccess := 0
    39  	c.Assert(exitCode, gc.Equals, exitSuccess)
    40  }