当前位置: 首页>>代码示例>>Golang>>正文


Golang backups.NewBackups函数代码示例

本文整理汇总了Golang中github.com/juju/juju/state/backups.NewBackups函数的典型用法代码示例。如果您正苦于以下问题:Golang NewBackups函数的具体用法?Golang NewBackups怎么用?Golang NewBackups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewBackups函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SetUpTest

func (s *backupsSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	storage, err := filestorage.NewSimpleStorage(c.MkDir())
	c.Assert(err, gc.IsNil)
	s.storage = storage

	s.api = backups.NewBackups(s.storage)
}
开发者ID:zhouqt,项目名称:juju,代码行数:9,代码来源:backups_test.go

示例2: NewAPI

// NewAPI creates a new instance of the Backups API facade.
func NewAPI(st *state.State, resources *common.Resources, authorizer common.Authorizer) (*API, error) {
	if !authorizer.AuthClient() {
		return nil, errors.Trace(common.ErrPerm)
	}

	stor, err := newBackupsStorage(st)
	if err != nil {
		return nil, errors.Trace(err)
	}

	b := API{
		st:      st,
		backups: backups.NewBackups(stor),
	}
	return &b, nil
}
开发者ID:zhouqt,项目名称:juju,代码行数:17,代码来源:backups.go

示例3: TestSuccessfulRequest

func (s *downloadSuite) TestSuccessfulRequest(c *gc.C) {
	store := backups.NewStorage(s.State)
	defer store.Close()
	backupsState := backups.NewBackups(store)

	r := strings.NewReader("<compressed archive data>")
	meta, err := backups.NewMetadataState(s.State, "0")
	c.Assert(err, jc.ErrorIsNil)
	// The Add method requires the length to be set
	// otherwise the content is assumed to have length 0.
	meta.Raw.Size = int64(r.Len())
	id, err := backupsState.Add(r, meta)
	c.Assert(err, jc.ErrorIsNil)
	resultArchive, err := s.client.Download(id)
	c.Assert(err, jc.ErrorIsNil)

	resultData, err := ioutil.ReadAll(resultArchive)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(string(resultData), gc.Equals, "<compressed archive data>")
}
开发者ID:exekias,项目名称:juju,代码行数:20,代码来源:download_test.go

示例4: extractResourceValue

func extractResourceValue(resources *common.Resources, key string) (string, error) {
	res := resources.Get(key)
	strRes, ok := res.(common.StringResource)
	if !ok {
		if res == nil {
			strRes = ""
		} else {
			return "", errors.Errorf("invalid %s resource: %v", key, res)
		}
	}
	return strRes.String(), nil
}

var newBackups = func(st *state.State) (backups.Backups, io.Closer) {
	stor := backups.NewStorage(st)
	return backups.NewBackups(stor), stor
}

// ResultFromMetadata updates the result with the information in the
// metadata value.
func ResultFromMetadata(meta *backups.Metadata) params.BackupsMetadataResult {
	var result params.BackupsMetadataResult

	result.ID = meta.ID()

	result.Checksum = meta.Checksum()
	result.ChecksumFormat = meta.ChecksumFormat()
	result.Size = meta.Size()
	if meta.Stored() != nil {
		result.Stored = *(meta.Stored())
	}
开发者ID:imoapps,项目名称:juju,代码行数:31,代码来源:backups.go

示例5: TestNewBackups

func (s *backupsSuite) TestNewBackups(c *gc.C) {
	api := backups.NewBackups(s.Storage)

	c.Check(api, gc.NotNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:5,代码来源:backups_test.go

示例6: SetUpTest

func (s *backupsSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	s.api = backups.NewBackups(s.Storage)
}
开发者ID:imoapps,项目名称:juju,代码行数:5,代码来源:backups_test.go


注:本文中的github.com/juju/juju/state/backups.NewBackups函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。