Exemplo n.º 1
0
func TestBlobStore(t *testing.T) {
	dir, err := ioutil.TempDir("", tstprefix)
	if err != nil {
		t.Fatalf("error creating tempdir: %v", err)
	}
	defer os.RemoveAll(dir)
	s, err := NewStore(dir)
	if err != nil {
		t.Fatalf("Unexpected error: %v", err)
	}
	for _, valueStr := range []string{
		"I am a manually placed object",
	} {
		s.stores[blobType].Write(types.NewHashSHA512([]byte(valueStr)).String(), []byte(valueStr))
	}

	s.Dump(false)
}
Exemplo n.º 2
0
func (ts *TestStore) WriteACI(path string) (string, error) {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		return "", err
	}
	imageID := types.NewHashSHA512(data)

	rs, err := os.Open(path)
	if err != nil {
		return "", err
	}
	defer rs.Close()
	im, err := aci.ManifestFromImage(rs)
	if err != nil {
		return "", fmt.Errorf("error retrieving ImageManifest: %v", err)
	}

	key := imageID.String()
	ts.acis[key] = &TestStoreAci{data: data, key: key, ImageManifest: im}
	return key, nil
}