Skip to content

Commit

Permalink
Add a backups abstraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Sep 8, 2014
1 parent 23492c0 commit 2afaa2c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
18 changes: 18 additions & 0 deletions state/backups/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ package backups

import (
"github.com/juju/loggo"
"github.com/juju/utils/filestorage"
)

var logger = loggo.GetLogger("juju.state.backups")

// Backups is an abstraction around all juju backup-related functionality.
type Backups interface {
}

type backups struct {
storage filestorage.FileStorage
}

// NewBackups returns a new Backups value using the provided DB info and
// file storage.
func NewBackups(stor filestorage.FileStorage) Backups {
b := backups{
storage: stor,
}
return &b
}
37 changes: 37 additions & 0 deletions state/backups/backups_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2013,2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.

package backups_test

import (
"github.com/juju/utils/filestorage"
gc "launchpad.net/gocheck"

"github.com/juju/juju/state/backups"
"github.com/juju/juju/testing"
)

type backupsSuite struct {
testing.BaseSuite

storage filestorage.FileStorage
api backups.Backups
}

var _ = gc.Suite(&backupsSuite{}) // Register the suite.

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)
}

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

c.Check(api, gc.NotNil)
}

0 comments on commit 2afaa2c

Please sign in to comment.