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

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package container_test
     5  
     6  import (
     7  	"github.com/juju/testing"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/container"
    11  	containertesting "github.com/juju/juju/container/testing"
    12  	"github.com/juju/juju/instance"
    13  	coretesting "github.com/juju/juju/testing"
    14  )
    15  
    16  type imageURLSuite struct {
    17  	coretesting.BaseSuite
    18  }
    19  
    20  var _ = gc.Suite(&imageURLSuite{})
    21  
    22  func (s *imageURLSuite) SetUpTest(c *gc.C) {
    23  	testing.PatchExecutable(c, s, "ubuntu-cloudimg-query", containertesting.FakeLxcURLScript)
    24  }
    25  
    26  func (s *imageURLSuite) TestImageURL(c *gc.C) {
    27  	imageURLGetter := container.NewImageURLGetter("host:port", "12345", []byte("cert"))
    28  	imageURL, err := imageURLGetter.ImageURL(instance.LXC, "trusty", "amd64")
    29  	c.Assert(err, gc.IsNil)
    30  	c.Assert(imageURL, gc.Equals, "https://host:port/environment/12345/images/lxc/trusty/amd64/trusty-released-amd64-root.tar.gz")
    31  	c.Assert(imageURLGetter.CACert(), gc.DeepEquals, []byte("cert"))
    32  }
    33  
    34  func (s *imageURLSuite) TestImageDownloadURL(c *gc.C) {
    35  	imageDownloadURL, err := container.ImageDownloadURL(instance.LXC, "trusty", "amd64")
    36  	c.Assert(err, gc.IsNil)
    37  	c.Assert(imageDownloadURL, gc.Equals, "test://cloud-images/trusty-released-amd64-root.tar.gz")
    38  }
    39  
    40  func (s *imageURLSuite) TestImageDownloadURLUnsupportedContainer(c *gc.C) {
    41  	_, err := container.ImageDownloadURL(instance.KVM, "trusty", "amd64")
    42  	c.Assert(err, gc.ErrorMatches, "unsupported container .*")
    43  }