-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
externalreality
committed
May 31, 2018
1 parent
f4dfbb3
commit cc07d2d
Showing
7 changed files
with
207 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2018 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package backups_test | ||
|
||
import ( | ||
gc "gopkg.in/check.v1" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/juju/juju/api/backups" | ||
|
||
"github.com/juju/juju/api/base/mocks" | ||
"github.com/juju/juju/apiserver/params" | ||
) | ||
|
||
type restoreSuite struct { | ||
} | ||
|
||
var _ = gc.Suite(&restoreSuite{}) | ||
|
||
func (s *restoreSuite) TestRestoreFromFileBackupExistsOnController(c *gc.C) { | ||
mockController := gomock.NewController(c) | ||
mockBackupFacadeCaller := mocks.NewMockFacadeCaller(mockController) | ||
mockBackupClientFacade := mocks.NewMockClientFacade(mockController) | ||
mockBackupClientFacade.EXPECT().Close().AnyTimes() | ||
|
||
// testBackupResults represents the parameters passed in by the client. | ||
testBackupResults := params.BackupsMetadataResult{ | ||
Checksum: "testCheckSum", | ||
} | ||
|
||
// This listBackupResults represents what is passed back from server. | ||
testBackupsListResults := params.BackupsListResult{ | ||
List: []params.BackupsMetadataResult{testBackupResults}, | ||
} | ||
|
||
// resultBackupList is an out param | ||
resultBackupList := ¶ms.BackupsListResult{} | ||
args := params.BackupsListArgs{} | ||
|
||
// Upload should never be called. If it is the test will fail. | ||
gomock.InOrder( | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("PrepareRestore", nil, gomock.Any()), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("List", args, resultBackupList).SetArg(2, testBackupsListResults), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("Restore", gomock.Any(), gomock.Any()).Times(1), | ||
mockBackupFacadeCaller.EXPECT().FacadeCall("FinishRestore", gomock.Any(), gomock.Any()).Times(1), | ||
) | ||
|
||
connFunc := func() (*backups.Client, error) { | ||
return backups.MakeClient(mockBackupClientFacade, mockBackupFacadeCaller, nil), nil | ||
} | ||
mockBackupsClient, _ := connFunc() | ||
mockBackupsClient.RestoreReader(nil, &testBackupResults, connFunc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.