本文整理汇总了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)
}
示例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
}
示例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>")
}
示例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())
}
示例5: TestNewBackups
func (s *backupsSuite) TestNewBackups(c *gc.C) {
api := backups.NewBackups(s.Storage)
c.Check(api, gc.NotNil)
}
示例6: SetUpTest
func (s *backupsSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.api = backups.NewBackups(s.Storage)
}