Skip to content

Commit

Permalink
Use jc.IsTrue and jc.IsFalse
Browse files Browse the repository at this point in the history
  • Loading branch information
howbazaar committed Nov 25, 2014
1 parent 24b83ad commit df2ce28
Show file tree
Hide file tree
Showing 153 changed files with 538 additions and 530 deletions.
10 changes: 5 additions & 5 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (*suite) TestMigrate(c *gc.C) {
// matches what we wrote.
configPath := agent.ConfigPath(newConfig.DataDir(), newConfig.Tag())
readConfig, err := agent.ReadConfig(configPath)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
c.Check(newConfig, jc.DeepEquals, readConfig)

// Make sure only the specified fields were changed and
Expand All @@ -333,15 +333,15 @@ func (*suite) TestMigrate(c *gc.C) {
switch field {
case "Values":
err = agent.PatchConfig(initialConfig, field, test.expectValues)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
case "DeleteValues":
err = agent.PatchConfig(initialConfig, field, test.newParams.DeleteValues)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
default:
value := reflect.ValueOf(test.newParams).FieldByName(field)
if value.IsValid() && test.expectErr == "" {
err = agent.PatchConfig(initialConfig, field, value.Interface())
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
} else {
err = agent.PatchConfig(initialConfig, field, value)
c.Check(err, gc.ErrorMatches, test.expectErr)
Expand Down Expand Up @@ -470,7 +470,7 @@ func (*suite) TestStateServingInfoNotAvailable(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

_, available := conf.StateServingInfo()
c.Assert(available, gc.Equals, false)
c.Assert(available, jc.IsFalse)
}

func (s *suite) TestAPIAddressesCannotWriteBack(c *gc.C) {
Expand Down
4 changes: 2 additions & 2 deletions agent/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *bootstrapSuite) TestInitializeState(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

_, available := cfg.StateServingInfo()
c.Assert(available, gc.Equals, true)
c.Assert(available, jc.IsTrue)
expectConstraints := constraints.MustParse("mem=1024M")
expectHW := instance.MustParseHardware("mem=2048M")
mcfg := agent.BootstrapMachineConfig{
Expand Down Expand Up @@ -179,7 +179,7 @@ func (s *bootstrapSuite) TestInitializeStateWithStateServingInfoNotAvailable(c *
c.Assert(err, jc.ErrorIsNil)

_, available := cfg.StateServingInfo()
c.Assert(available, gc.Equals, false)
c.Assert(available, jc.IsFalse)

adminUser := names.NewLocalUserTag("agent-admin")
_, _, err = agent.InitializeState(adminUser, cfg, nil, agent.BootstrapMachineConfig{}, mongo.DialOpts{}, environs.NewStatePolicy())
Expand Down
2 changes: 1 addition & 1 deletion agent/format-1.16_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (*format_1_16Suite) TestStatePortParsed(c *gc.C) {
readConfig, err := ReadConfig(configPath)
c.Assert(err, jc.ErrorIsNil)
info, available := readConfig.StateServingInfo()
c.Assert(available, gc.Equals, true)
c.Assert(available, jc.IsTrue)
c.Assert(info.StatePort, gc.Equals, 37017)
}

Expand Down
2 changes: 1 addition & 1 deletion agent/format-1.18_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *format_1_18Suite) TestStatePortNotParsedWithoutSecret(c *gc.C) {
readConfig, err := ReadConfig(configPath)
c.Assert(err, jc.ErrorIsNil)
_, available := readConfig.StateServingInfo()
c.Assert(available, gc.Equals, false)
c.Assert(available, jc.IsFalse)
}

func (*format_1_18Suite) TestReadConfWithExisting1_18ConfigFileContents(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion api/action/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (s *actionSuite) TestServiceCharmActions(c *gc.C) {
if t.expectedErr != "" {
c.Check(err, gc.ErrorMatches, t.expectedErr)
} else {
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
c.Check(result, jc.DeepEquals, t.expectedResult)
}
}()
Expand Down
6 changes: 3 additions & 3 deletions api/agent/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *servingInfoSuite) TestIsMaster(c *gc.C) {

c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.Equals, expected)
c.Assert(calledIsMaster, gc.Equals, true)
c.Assert(calledIsMaster, jc.IsTrue)
}

func (s *servingInfoSuite) TestIsMasterPermission(c *gc.C) {
Expand Down Expand Up @@ -137,8 +137,8 @@ func (s *machineSuite) TestEntitySetPassword(c *gc.C) {

err = s.machine.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.machine.PasswordValid("bar"), gc.Equals, false)
c.Assert(s.machine.PasswordValid("foo-12345678901234567890"), gc.Equals, true)
c.Assert(s.machine.PasswordValid("bar"), jc.IsFalse)
c.Assert(s.machine.PasswordValid("foo-12345678901234567890"), jc.IsTrue)

// Check that we cannot log in to mongo with the correct password.
// This is because there's no mongo password set for s.machine,
Expand Down
4 changes: 2 additions & 2 deletions api/apiclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (s *apiclientSuite) TestOpenPrefersLocalhostIfPresent(c *gc.C) {
// listenAddress contains the actual IP address, but APIHostPorts
// is going to report localhost, so just find the port
_, port, err := net.SplitHostPort(listenerAddress)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
portNum, err := strconv.Atoi(port)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
expectedHostPort := fmt.Sprintf("localhost:%d", portNum)
info.Addrs = []string{"fakeAddress:1", "fakeAddress:1", expectedHostPort}
st, err := api.Open(info, api.DialOpts{})
Expand Down
4 changes: 2 additions & 2 deletions api/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func (s *deployerSuite) TestUnitSetPassword(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
err = s.principal.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.principal.PasswordValid("foobar-12345678901234567890"), gc.Equals, true)
c.Assert(s.principal.PasswordValid("foobar-12345678901234567890"), jc.IsTrue)

// Then the subordinate.
unit, err = s.st.Unit(s.subordinate.Tag().(names.UnitTag))
Expand All @@ -225,7 +225,7 @@ func (s *deployerSuite) TestUnitSetPassword(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
err = s.subordinate.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.subordinate.PasswordValid("phony-12345678901234567890"), gc.Equals, true)
c.Assert(s.subordinate.PasswordValid("phony-12345678901234567890"), jc.IsTrue)
}

func (s *deployerSuite) TestStateAddresses(c *gc.C) {
Expand Down
5 changes: 3 additions & 2 deletions api/diskmanager/diskmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"

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

"github.com/juju/juju/api/base/testing"
Expand Down Expand Up @@ -56,7 +57,7 @@ func (s *DiskManagerSuite) TestSetMachineBlockDevices(c *gc.C) {

st := diskmanager.NewState(apiCaller, names.NewMachineTag("123"))
err := st.SetMachineBlockDevices(devices)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
c.Check(callCount, gc.Equals, 1)
}

Expand All @@ -79,7 +80,7 @@ func (s *DiskManagerSuite) TestSetMachineBlockDevicesNil(c *gc.C) {
})
st := diskmanager.NewState(apiCaller, names.NewMachineTag("123"))
err := st.SetMachineBlockDevices(nil)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
c.Check(callCount, gc.Equals, 1)
}

Expand Down
6 changes: 3 additions & 3 deletions api/firewaller/firewaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ func (s *firewallerSuite) SetUpTest(c *gc.C) {
// to be numerically consecutive from zero.
for i := 1; i <= 2; i++ {
s.machines[i], err = s.State.AddMachine("quantal", state.JobHostUnits)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
// Create a service and three units for these machines.
s.charm = s.AddTestingCharm(c, "wordpress")
s.service = s.AddTestingService(c, "wordpress", s.charm)
// Add the rest of the units and assign them.
for i := 0; i <= 2; i++ {
s.units[i], err = s.service.AddUnit()
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
err = s.units[i].AssignToMachine(s.machines[i])
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}

// Create the firewaller API facade.
Expand Down
2 changes: 1 addition & 1 deletion api/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s *stateSuite) TestLoginSetsEnvironTag(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
// Now that we've logged in, EnvironTag should be updated correctly.
envTag, err = apistate.EnvironTag()
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
c.Check(envTag, gc.Equals, env.EnvironTag())
}

Expand Down
16 changes: 8 additions & 8 deletions apiserver/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func (s *loginSuite) TestDelayLogins(c *gc.C) {
}
select {
case err := <-errResults:
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out while waiting for Login to finish")
}
Expand All @@ -384,7 +384,7 @@ func (s *loginSuite) TestDelayLogins(c *gc.C) {
close(errResults)
successCount := 0
for err := range errResults {
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
if err == nil {
successCount += 1
}
Expand Down Expand Up @@ -416,7 +416,7 @@ func (s *loginSuite) TestLoginRateLimited(c *gc.C) {
delayChan <- struct{}{}
select {
case err := <-errResults:
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out expecting one login to succeed")
}
Expand Down Expand Up @@ -444,7 +444,7 @@ func (s *loginSuite) TestLoginRateLimited(c *gc.C) {
wg.Wait()
close(errResults)
for err := range errResults {
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
}

Expand Down Expand Up @@ -485,13 +485,13 @@ func (s *loginSuite) TestUsersLoginWhileRateLimited(c *gc.C) {
machineCount := 0
for err := range machineResults {
machineCount += 1
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
c.Check(machineCount, gc.Equals, apiserver.LoginRateLimit)
userCount := 0
for err := range userResults {
userCount += 1
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
c.Check(userCount, gc.Equals, apiserver.LoginRateLimit+1)
}
Expand Down Expand Up @@ -519,7 +519,7 @@ func (s *loginSuite) TestUsersAreNotRateLimited(c *gc.C) {
wg.Wait()
close(errResults)
for err := range errResults {
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
}

Expand Down Expand Up @@ -583,7 +583,7 @@ func (s *loginV1Suite) TestLoginV1Valid(c *gc.C) {
c.Assert(result.UserInfo, gc.NotNil)
c.Assert(result.UserInfo.LastConnection, gc.NotNil)
c.Assert(result.UserInfo.Identity, gc.Equals, userTag.String())
c.Assert(time.Now().Unix()-result.UserInfo.LastConnection.Unix() < 300, gc.Equals, true)
c.Assert(time.Now().Unix()-result.UserInfo.LastConnection.Unix() < 300, jc.IsTrue)
}

func (s *loginV1Suite) TestLoginRejectV0(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/agent/agent_v0_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *baseSuite) testSetPasswordsV0(c *gc.C, api setPasswordsV0) {
err = s.machine1.Refresh()
c.Assert(err, jc.ErrorIsNil)
changed := s.machine1.PasswordValid("yyy-12345678901234567890")
c.Assert(changed, gc.Equals, true)
c.Assert(changed, jc.IsTrue)
}

func (s *baseSuite) testSetPasswordsShortV0(c *gc.C, api setPasswordsV0) {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/authentication/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (s *agentAuthenticatorSuite) TestValidLogins(c *gc.C) {
c.Logf("test %d: %s", i, t.about)
var authenticator authentication.AgentAuthenticator
err := authenticator.Authenticate(t.entity, t.credentials, t.nonce)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}
}

Expand Down
4 changes: 2 additions & 2 deletions apiserver/backups/backups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func (s *backupsSuite) setBackups(c *gc.C, meta *backups.Metadata, err string) *

func (s *backupsSuite) TestRegistered(c *gc.C) {
_, err := common.Facades.GetType("Backups", 0)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}

func (s *backupsSuite) TestNewAPIOkay(c *gc.C) {
_, err := backupsAPI.NewAPI(s.State, s.resources, s.authorizer)
c.Check(err, gc.IsNil)
c.Check(err, jc.ErrorIsNil)
}

func (s *backupsSuite) TestNewAPINotAuthorized(c *gc.C) {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/charmrevisionupdater/testing/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *CharmSuite) AddCharmWithRevision(c *gc.C, charmName string, rev int) *s
// AddService adds a service for the specified charm to state.
func (s *CharmSuite) AddService(c *gc.C, charmName, serviceName string, networks []string) {
ch, ok := s.charms[charmName]
c.Assert(ok, gc.Equals, true)
c.Assert(ok, jc.IsTrue)
owner := s.jcSuite.AdminUserTag(c)
_, err := s.jcSuite.State.AddService(serviceName, owner.String(), ch, networks)
c.Assert(err, jc.ErrorIsNil)
Expand Down
6 changes: 3 additions & 3 deletions apiserver/client/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (s *baseSuite) setUpScenario(c *gc.C) (entities []names.Tag) {
c.Assert(err, jc.ErrorIsNil)

deployer, ok := wu.DeployerTag()
c.Assert(ok, gc.Equals, true)
c.Assert(ok, jc.IsTrue)
c.Assert(deployer, gc.Equals, names.NewMachineTag(fmt.Sprintf("%d", i+1)))

wru, err := rel.Unit(wu)
Expand All @@ -401,9 +401,9 @@ func (s *baseSuite) setUpScenario(c *gc.C) (entities []names.Tag) {

lu, err := s.State.Unit(fmt.Sprintf("logging/%d", i))
c.Assert(err, jc.ErrorIsNil)
c.Assert(lu.IsPrincipal(), gc.Equals, false)
c.Assert(lu.IsPrincipal(), jc.IsFalse)
deployer, ok = lu.DeployerTag()
c.Assert(ok, gc.Equals, true)
c.Assert(ok, jc.IsTrue)
c.Assert(deployer, gc.Equals, names.NewUnitTag(fmt.Sprintf("wordpress/%d", i)))
setDefaultPassword(c, lu)
add(lu)
Expand Down
Loading

0 comments on commit df2ce28

Please sign in to comment.