Example #1
0
func (s *lightweightSuite) TestMapAppWithPart(c *check.C) {
	snap := remote.Snap{
		Name:         "foo",
		Origin:       "bar",
		Version:      "2",
		Type:         snap.TypeApp,
		IconURL:      "http://example.com/icon",
		DownloadSize: 42,
	}
	part := snappy.NewRemoteSnapPart(snap)

	bag := PartBagByName("foo", "bar")
	m := bag.Map(part)
	c.Check(m["installed_size"], check.FitsTypeOf, int64(0))
	delete(m, "installed_size")
	c.Check(m, check.DeepEquals, map[string]interface{}{
		"name":             "foo",
		"origin":           "bar",
		"status":           "active",
		"version":          "1.0",
		"icon":             filepath.Join(s.d, "snaps", "foo.bar", "1.0", "meta/icon.png"),
		"type":             "app",
		"vendor":           "",
		"download_size":    int64(42),
		"description":      "",
		"update_available": "2",
	})
}
Example #2
0
func (s *lightweightSuite) TestMapAppNoPartBag(c *check.C) {
	snap := remote.Snap{
		Name:         "foo",
		Origin:       "bar",
		Version:      "2",
		Type:         snap.TypeApp,
		IconURL:      "http://example.com/icon",
		Publisher:    "example.com",
		DownloadSize: 42,
	}
	part := snappy.NewRemoteSnapPart(snap)

	m := (*PartBag)(nil).Map(part)
	c.Check(m, check.DeepEquals, map[string]interface{}{
		"name":           "foo",
		"origin":         "bar",
		"status":         "not installed",
		"version":        "2",
		"icon":           snap.IconURL,
		"type":           "app",
		"vendor":         "",
		"installed_size": int64(-1),
		"download_size":  int64(42),
		"description":    "",
	})

}
Example #3
0
func (s *lightweightSuite) TestMapRemovedFmkNoPartButStoreMeta(c *check.C) {
	snap := remote.Snap{
		Name:         "fmk2",
		Origin:       "fmk2origin",
		Version:      "4.2.0ubuntu1",
		Type:         snap.TypeFramework,
		IconURL:      "http://example.com/icon",
		DownloadSize: 42,
		Publisher:    "Example Inc.",
	}
	part := snappy.NewRemoteSnapPart(snap)

	content, err := yaml.Marshal(snap)
	c.Assert(err, check.IsNil)

	p := snappy.RemoteManifestPath(part)
	c.Assert(os.MkdirAll(filepath.Dir(p), 0755), check.IsNil)
	c.Assert(ioutil.WriteFile(p, content, 0644), check.IsNil)

	bag := PartBagByName("fmk2", "fmk2origin")
	m := bag.Map(nil)
	c.Check(m, check.DeepEquals, map[string]interface{}{
		"name":           "fmk2",
		"origin":         "fmk2origin",
		"status":         "removed",
		"version":        "4.2.0ubuntu1",
		"icon":           "http://example.com/icon",
		"type":           "framework",
		"vendor":         "",
		"installed_size": int64(-1),
		"download_size":  int64(42),
		"description":    "",
	})
}