github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/payload/id_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package payload_test
     5  
     6  import (
     7  	"github.com/juju/testing"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/payload"
    11  )
    12  
    13  var _ = gc.Suite(&idSuite{})
    14  
    15  type idSuite struct {
    16  	testing.IsolationSuite
    17  }
    18  
    19  func (s *idSuite) TestParseIDFull(c *gc.C) {
    20  	name, id := payload.ParseID("a-payload/my-payload")
    21  
    22  	c.Check(name, gc.Equals, "a-payload")
    23  	c.Check(id, gc.Equals, "my-payload")
    24  }
    25  
    26  func (s *idSuite) TestParseIDNameOnly(c *gc.C) {
    27  	name, id := payload.ParseID("a-payload")
    28  
    29  	c.Check(name, gc.Equals, "a-payload")
    30  	c.Check(id, gc.Equals, "")
    31  }
    32  
    33  func (s *idSuite) TestParseIDExtras(c *gc.C) {
    34  	name, id := payload.ParseID("somecharm/0/a-payload/my-payload")
    35  
    36  	c.Check(name, gc.Equals, "somecharm")
    37  	c.Check(id, gc.Equals, "0/a-payload/my-payload")
    38  }