Example #1
0
func (s *marshalSuite) TestLargeNumber(c *gc.C) {
	metadata := []*tools.ToolsMetadata{
		&tools.ToolsMetadata{
			Release:  "saucy",
			Version:  "1.2.3.4",
			Arch:     "arm",
			Size:     9223372036854775807,
			Path:     "/somewhere/over/the/rainbow.tar.gz",
			FileType: "tar.gz",
		},
	}
	_, products, err := tools.MarshalToolsMetadataJSON(metadata, time.Now())
	c.Assert(err, gc.IsNil)
	c.Assert(string(products), jc.Contains, `"size": 9223372036854775807`)
}
Example #2
0
func generateMetadata(c *gc.C, versions ...version.Binary) []metadataFile {
	var metadata = make([]*tools.ToolsMetadata, len(versions))
	for i, vers := range versions {
		basePath := fmt.Sprintf("releases/tools-%s.tar.gz", vers.String())
		metadata[i] = &tools.ToolsMetadata{
			Release: vers.Series,
			Version: vers.Number.String(),
			Arch:    vers.Arch,
			Path:    basePath,
		}
	}
	index, products, err := tools.MarshalToolsMetadataJSON(metadata, time.Now())
	c.Assert(err, gc.IsNil)
	objects := []metadataFile{
		{simplestreams.UnsignedIndex, index},
		{tools.ProductMetadataPath, products},
	}
	return objects
}
Example #3
0
func (s *marshalSuite) TestMarshal(c *gc.C) {
	index, products, err := tools.MarshalToolsMetadataJSON(toolMetadataForTesting, time.Unix(0, 0).UTC())
	c.Assert(err, gc.IsNil)
	c.Assert(string(index), gc.Equals, expectedIndex)
	c.Assert(string(products), gc.Equals, expectedProducts)
}