當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。