Skip to content

Commit

Permalink
I think I have them all now.
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Aug 21, 2018
1 parent 8c129f3 commit 3951bdb
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 24 deletions.
5 changes: 3 additions & 2 deletions provider/azure/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/go-autorest/autorest/mocks"
"github.com/Azure/go-autorest/autorest/to"
"github.com/juju/clock/testclock"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
Expand Down Expand Up @@ -132,7 +133,7 @@ func (s *environSuite) SetUpTest(c *gc.C) {
}
s.sender = nil
s.requests = nil
s.retryClock = mockClock{Clock: gitjujutesting.NewClock(time.Time{})}
s.retryClock = mockClock{Clock: testclock.NewClock(time.Time{})}

s.provider = newProvider(c, azure.ProviderConfig{
Sender: azuretesting.NewSerialSender(&s.sender),
Expand Down Expand Up @@ -477,7 +478,7 @@ func assertRequestBody(c *gc.C, req *http.Request, expect interface{}) {

type mockClock struct {
gitjujutesting.Stub
*gitjujutesting.Clock
*testclock.Clock
}

func (c *mockClock) After(d time.Duration) <-chan time.Time {
Expand Down
3 changes: 2 additions & 1 deletion provider/oci/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"time"

"github.com/juju/clock/testclock"
gitjujutesting "github.com/juju/testing"
"github.com/juju/utils/arch"
"github.com/juju/version"
Expand All @@ -24,7 +25,7 @@ import (
"github.com/juju/juju/tools"
)

var clk = gitjujutesting.NewClock(time.Time{})
var clk = testclock.NewClock(time.Time{})
var advancingClock = gitjujutesting.AutoAdvancingClock{clk, clk.Advance}

func makeToolsList(series string) tools.List {
Expand Down
5 changes: 3 additions & 2 deletions provider/openstack/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"time"

"github.com/juju/clock/testclock"
"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/os/series"
Expand Down Expand Up @@ -681,7 +682,7 @@ func (s *localServerSuite) TestStartInstanceWaitForActiveDetails(c *gc.C) {
defer s.srv.Nova.SetServerStatus("")

// Make time advance in zero time
clk := gitjujutesting.NewClock(time.Time{})
clk := testclock.NewClock(time.Time{})
clock := gitjujutesting.AutoAdvancingClock{clk, clk.Advance}
env.(*openstack.Environ).SetClock(&clock)

Expand Down Expand Up @@ -777,7 +778,7 @@ func (s *localServerSuite) TestStopInstanceSecurityGroupNotDeleted(c *gc.C) {
assertSecurityGroups(c, env, allSecurityGroups)

// Make time advance in zero time
clk := gitjujutesting.NewClock(time.Time{})
clk := testclock.NewClock(time.Time{})
clock := gitjujutesting.AutoAdvancingClock{clk, clk.Advance}
env.(*openstack.Environ).SetClock(&clock)

Expand Down
3 changes: 2 additions & 1 deletion provider/oracle/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"time"

"github.com/juju/clock/testclock"
gitjujutesting "github.com/juju/testing"
"github.com/juju/utils/arch"
"github.com/juju/version"
Expand Down Expand Up @@ -58,7 +59,7 @@ func (e *environSuite) SetUpTest(c *gc.C) {
var _ = gc.Suite(&environSuite{})

// shamelessly copied from one of the OpenStack tests
var clk = gitjujutesting.NewClock(time.Time{})
var clk = testclock.NewClock(time.Time{})
var advancingClock = gitjujutesting.AutoAdvancingClock{clk, clk.Advance}

func (e *environSuite) TestAvailabilityZone(c *gc.C) {
Expand Down
3 changes: 2 additions & 1 deletion provider/oracle/network/firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package network_test
import (
"time"

"github.com/juju/clock/testclock"
"github.com/juju/errors"
"github.com/juju/go-oracle-cloud/api"
"github.com/juju/go-oracle-cloud/common"
Expand Down Expand Up @@ -34,7 +35,7 @@ func (f *firewallSuite) SetUpTest(c *gc.C) {
f.callCtx = context.NewCloudCallContext()
}

var clk = gitjujutesting.NewClock(time.Time{})
var clk = testclock.NewClock(time.Time{})
var advancingClock = gitjujutesting.AutoAdvancingClock{clk, clk.Advance}

type fakeEnvironConfig struct {
Expand Down
10 changes: 5 additions & 5 deletions state/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"time"

"github.com/juju/clock/testclock"
"github.com/juju/errors"
test "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/txn"
"github.com/juju/utils"
Expand Down Expand Up @@ -985,7 +985,7 @@ type ActionPruningSuite struct {
var _ = gc.Suite(&ActionPruningSuite{})

func (s *ActionPruningSuite) TestPruneActionsBySize(c *gc.C) {
clock := test.NewClock(coretesting.NonZeroTime())
clock := testclock.NewClock(coretesting.NonZeroTime())
err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
application := s.Factory.MakeApplication(c, nil)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ func (s *ActionPruningSuite) TestPruneActionsBySize(c *gc.C) {
}

func (s *ActionPruningSuite) TestPruneActionsBySizeOldestFirst(c *gc.C) {
clock := test.NewClock(coretesting.NonZeroTime())
clock := testclock.NewClock(coretesting.NonZeroTime())
err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
application := s.Factory.MakeApplication(c, nil)
Expand Down Expand Up @@ -1057,7 +1057,7 @@ func (s *ActionPruningSuite) TestPruneActionsBySizeOldestFirst(c *gc.C) {
}

func (s *ActionPruningSuite) TestPruneActionByAge(c *gc.C) {
clock := test.NewClock(time.Now())
clock := testclock.NewClock(time.Now())
err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
application := s.Factory.MakeApplication(c, nil)
Expand Down Expand Up @@ -1088,7 +1088,7 @@ func (s *ActionPruningSuite) TestPruneActionByAge(c *gc.C) {
// Pruner should not prune actions with age of epoch time since the epoch is a
// special value denoting an incomplete action.
func (s *ActionPruningSuite) TestDoNotPruneIncompleteActions(c *gc.C) {
clock := test.NewClock(time.Now())
clock := testclock.NewClock(time.Now())
err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
application := s.Factory.MakeApplication(c, nil)
Expand Down
3 changes: 2 additions & 1 deletion state/backups/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strconv"
"strings"

"github.com/juju/clock/testclock"
"github.com/juju/replicaset"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
Expand Down Expand Up @@ -217,7 +218,7 @@ func (r *RestoreSuite) TestNewConnection(c *gc.C) {
ctlr, st := statetesting.InitializeWithArgs(c,
statetesting.InitializeArgs{
Owner: names.NewLocalUserTag("test-admin"),
Clock: gitjujutesting.NewClock(coretesting.NonZeroTime()),
Clock: testclock.NewClock(coretesting.NonZeroTime()),
})
c.Assert(st.Close(), jc.ErrorIsNil)
c.Assert(ctlr.Close(), jc.ErrorIsNil)
Expand Down
4 changes: 2 additions & 2 deletions state/singular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package state_test
import (
"time"

gitjujutesting "github.com/juju/testing"
"github.com/juju/clock/testclock"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

Expand Down Expand Up @@ -104,7 +104,7 @@ func (s *SingularSuite) TestSingularClaimerRestarts(c *gc.C) {

// SetClockForTesting will restart the workers, and
// will have replaced them by the time it returns.
s.State.SetClockForTesting(gitjujutesting.NewClock(time.Time{}))
s.State.SetClockForTesting(testclock.NewClock(time.Time{}))

err := claimer.Claim(s.modelTag.Id(), "machine-123", time.Minute)
c.Assert(err, jc.ErrorIsNil)
Expand Down
6 changes: 3 additions & 3 deletions state/state_leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package state_test
import (
"time" // Only used for time types.

"github.com/juju/clock/testclock"
"github.com/juju/errors"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"gopkg.in/mgo.v2/txn"
Expand Down Expand Up @@ -135,7 +135,7 @@ func (s *LeadershipSuite) TestCloseStateUnblocksClaimer(c *gc.C) {
func (s *LeadershipSuite) TestLeadershipClaimerRestarts(c *gc.C) {
// SetClockForTesting will restart the workers, and
// will have replaced them by the time it returns.
s.State.SetClockForTesting(gitjujutesting.NewClock(time.Time{}))
s.State.SetClockForTesting(testclock.NewClock(time.Time{}))

err := s.claimer.ClaimLeadership("blah", "blah/0", time.Minute)
c.Assert(err, jc.ErrorIsNil)
Expand All @@ -147,7 +147,7 @@ func (s *LeadershipSuite) TestLeadershipCheckerRestarts(c *gc.C) {

// SetClockForTesting will restart the workers, and
// will have replaced them by the time it returns.
s.State.SetClockForTesting(gitjujutesting.NewClock(time.Time{}))
s.State.SetClockForTesting(testclock.NewClock(time.Time{}))

token := s.checker.LeadershipCheck("application", "application/0")
err = token.Check(nil)
Expand Down
3 changes: 2 additions & 1 deletion state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/juju/clock"
"github.com/juju/clock/testclock"
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/os/series"
Expand Down Expand Up @@ -4678,7 +4679,7 @@ func (s *StateSuite) testOpenParams() state.OpenParams {

func (s *StateSuite) TestControllerTimestamp(c *gc.C) {
now := testing.NonZeroTime()
clock := gitjujutesting.NewClock(now)
clock := testclock.NewClock(now)

err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
Expand Down
5 changes: 3 additions & 2 deletions state/watcher/txnwatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package watcher_test
import (
"time"

"github.com/juju/clock/testclock"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
Expand All @@ -28,7 +29,7 @@ type TxnWatcherSuite struct {
w *watcher.TxnWatcher
ch chan watcher.Change
iteratorFunc func() mongo.Iterator
clock *gitjujutesting.Clock
clock *testclock.Clock
}

var _ = gc.Suite(&TxnWatcherSuite{})
Expand Down Expand Up @@ -56,7 +57,7 @@ func (s *TxnWatcherSuite) SetUpTest(c *gc.C) {
s.stash = db.C("txn.stash")
s.runner = txn.NewRunner(db.C("txn"))
s.runner.ChangeLog(s.log)
s.clock = gitjujutesting.NewClock(time.Now())
s.clock = testclock.NewClock(time.Now())
}

func (s *TxnWatcherSuite) TearDownTest(c *gc.C) {
Expand Down
7 changes: 4 additions & 3 deletions worker/instancepoller/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/juju/clock"
"github.com/juju/clock/testclock"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
Expand Down Expand Up @@ -132,7 +133,7 @@ func (s *machineSuite) TestNoPollWhenNotProvisioned(c *gc.C) {
}
died := make(chan machine)

clock := gitjujutesting.NewClock(time.Time{})
clock := testclock.NewClock(time.Time{})
changed := make(chan struct{})
go runMachine(context, m, changed, died, clock)

Expand Down Expand Up @@ -486,11 +487,11 @@ func (m *testMachine) Life() params.Life {

type testClock struct {
gitjujutesting.Stub
*gitjujutesting.Clock
*testclock.Clock
}

func newTestClock() *testClock {
clock := gitjujutesting.NewClock(time.Time{})
clock := testclock.NewClock(time.Time{})
return &testClock{Clock: clock}
}

Expand Down

0 comments on commit 3951bdb

Please sign in to comment.