forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upgradesteps_test.go
76 lines (59 loc) · 2.12 KB
/
upgradesteps_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2019 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package upgradesteps_test
import (
"github.com/golang/mock/gomock"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/juju/names.v2"
"github.com/juju/juju/api/base/mocks"
"github.com/juju/juju/api/upgradesteps"
"github.com/juju/juju/apiserver/params"
jujutesting "github.com/juju/juju/testing"
)
type upgradeStepsSuite struct {
jujutesting.BaseSuite
tag names.Tag
arg params.Entity
fCaller *mocks.MockFacadeCaller
}
var _ = gc.Suite(&upgradeStepsSuite{})
func (s *upgradeStepsSuite) SetUpTest(c *gc.C) {
s.tag = names.NewMachineTag("0/kvm/0")
s.arg = params.Entity{Tag: s.tag.String()}
s.BaseSuite.SetUpTest(c)
}
func (s *upgradeStepsSuite) TestResetKVMMachineModificationStatusIdle(c *gc.C) {
defer s.setupMocks(c).Finish()
s.expectResetKVMMachineModificationStatusIdleSuccess()
client := upgradesteps.NewClientFromFacade(s.fCaller)
err := client.ResetKVMMachineModificationStatusIdle(s.tag)
c.Assert(err, jc.ErrorIsNil)
}
func (s *upgradeStepsSuite) TestResetKVMMachineModificationStatusIdleError(c *gc.C) {
defer s.setupMocks(c).Finish()
s.expectResetKVMMachineModificationStatusIdleError()
client := upgradesteps.NewClientFromFacade(s.fCaller)
err := client.ResetKVMMachineModificationStatusIdle(s.tag)
c.Assert(err, gc.ErrorMatches, "did not find")
}
func (s *upgradeStepsSuite) setupMocks(c *gc.C) *gomock.Controller {
ctrl := gomock.NewController(c)
s.fCaller = mocks.NewMockFacadeCaller(ctrl)
return ctrl
}
func (s *upgradeStepsSuite) expectResetKVMMachineModificationStatusIdleSuccess() {
fExp := s.fCaller.EXPECT()
resultSource := params.ErrorResult{}
fExp.FacadeCall("ResetKVMMachineModificationStatusIdle", s.arg, gomock.Any()).SetArg(2, resultSource)
}
func (s *upgradeStepsSuite) expectResetKVMMachineModificationStatusIdleError() {
fExp := s.fCaller.EXPECT()
resultSource := params.ErrorResult{
Error: ¶ms.Error{
Code: params.CodeNotFound,
Message: "did not find",
},
}
fExp.FacadeCall("ResetKVMMachineModificationStatusIdle", s.arg, gomock.Any()).SetArg(2, resultSource)
}