Пример #1
0
func createDatastoreFiles(d *Dispatcher, ds *object.Datastore, t *testing.T) error {
	tmpfile, err := ioutil.TempFile("", "tempDatastoreFile.vmdk")
	if err != nil {
		t.Errorf("Failed to create file: %s", err)
		return err
	}

	defer os.Remove(tmpfile.Name()) // clean up

	if err = ds.UploadFile(d.ctx, tmpfile.Name(), "Test/folder/data/temp.vmdk", nil); err != nil {
		t.Errorf("Failed to upload file %q: %s", "Test/folder/data/temp.vmdk", err)
		return err
	}
	if err = ds.UploadFile(d.ctx, tmpfile.Name(), "Test/folder/tempMetadata", nil); err != nil {
		t.Errorf("Failed to upload file %q: %s", "Test/folder/tempMetadata", err)
		return err
	}
	return nil
}