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

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package resource_test
     5  
     6  import (
     7  	"strings"
     8  	"time"
     9  
    10  	jc "github.com/juju/testing/checkers"
    11  	gc "gopkg.in/check.v1"
    12  	charmresource "gopkg.in/juju/charm.v6-unstable/resource"
    13  
    14  	"github.com/juju/juju/resource"
    15  )
    16  
    17  func newFingerprint(c *gc.C, data string) charmresource.Fingerprint {
    18  	reader := strings.NewReader(data)
    19  	fp, err := charmresource.GenerateFingerprint(reader)
    20  	c.Assert(err, jc.ErrorIsNil)
    21  	return fp
    22  }
    23  
    24  func newFullCharmResource(c *gc.C, name string) charmresource.Resource {
    25  	return charmresource.Resource{
    26  		Meta: charmresource.Meta{
    27  			Name:        name,
    28  			Type:        charmresource.TypeFile,
    29  			Path:        name + ".tgz",
    30  			Description: "you need it",
    31  		},
    32  		Origin:      charmresource.OriginUpload,
    33  		Revision:    1,
    34  		Fingerprint: newFingerprint(c, name),
    35  	}
    36  }
    37  
    38  func newFullResource(c *gc.C, name string) resource.Resource {
    39  	return resource.Resource{
    40  		Resource:      newFullCharmResource(c, name),
    41  		ID:            "a-application/" + name,
    42  		ApplicationID: "a-application",
    43  		Username:      "a-user",
    44  		Timestamp:     time.Now(),
    45  	}
    46  }