~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/backups/export_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "github.com/juju/cmd"
8
8
 
 
9
        "github.com/juju/juju/apiserver/params"
9
10
        "github.com/juju/juju/cmd/modelcmd"
 
11
        "github.com/juju/juju/environs"
 
12
        "github.com/juju/juju/jujuclient"
10
13
)
11
14
 
12
15
const (
62
65
        return modelcmd.Wrap(c)
63
66
}
64
67
 
65
 
func NewRestoreCommand() cmd.Command {
66
 
        c := &restoreCommand{}
 
68
func NewRestoreCommandForTest(
 
69
        store jujuclient.ClientStore,
 
70
        api RestoreAPI,
 
71
        getArchive func(string) (ArchiveReader, *params.BackupsMetadataResult, error),
 
72
        getEnviron func(string, *params.BackupsMetadataResult) (environs.Environ, error),
 
73
) cmd.Command {
 
74
        c := &restoreCommand{
 
75
                getArchiveFunc: getArchive,
 
76
                getEnvironFunc: getEnviron,
 
77
                newAPIClientFunc: func() (RestoreAPI, error) {
 
78
                        return api, nil
 
79
                }}
 
80
        if getEnviron == nil {
 
81
                c.getEnvironFunc = func(controllerNme string, meta *params.BackupsMetadataResult) (environs.Environ, error) {
 
82
                        return c.getEnviron(controllerNme, meta)
 
83
                }
 
84
        }
67
85
        c.Log = &cmd.Log{}
 
86
        c.SetClientStore(store)
68
87
        return modelcmd.Wrap(c)
69
88
}