本文整理汇总了Golang中gopkg/in/check/v1.Not函数的典型用法代码示例。如果您正苦于以下问题:Golang Not函数的具体用法?Golang Not怎么用?Golang Not使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Not函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDecodeCheckInvalidSignature
func (s *decodeSuite) TestDecodeCheckInvalidSignature(c *gc.C) {
r := bytes.NewReader([]byte(invalidClearsignInput + signSuffix))
_, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
c.Assert(err, gc.Not(gc.IsNil))
_, ok := err.(*simplestreams.NotPGPSignedError)
c.Assert(ok, jc.IsFalse)
}
示例2: TestPasswordValidUpdatesSalt
func (s *UserSuite) TestPasswordValidUpdatesSalt(c *gc.C) {
user := s.Factory.MakeUser(c, nil)
compatHash := utils.UserPasswordHash("foo", utils.CompatSalt)
err := user.SetPasswordHash(compatHash, "")
c.Assert(err, jc.ErrorIsNil)
beforeSalt, beforeHash := state.GetUserPasswordSaltAndHash(user)
c.Assert(beforeSalt, gc.Equals, "")
c.Assert(beforeHash, gc.Equals, compatHash)
c.Assert(user.PasswordValid("bar"), jc.IsFalse)
// A bad password doesn't trigger a rewrite
afterBadSalt, afterBadHash := state.GetUserPasswordSaltAndHash(user)
c.Assert(afterBadSalt, gc.Equals, "")
c.Assert(afterBadHash, gc.Equals, compatHash)
// When we get a valid check, we then add a salt and rewrite the hash
c.Assert(user.PasswordValid("foo"), jc.IsTrue)
afterSalt, afterHash := state.GetUserPasswordSaltAndHash(user)
c.Assert(afterSalt, gc.Not(gc.Equals), "")
c.Assert(afterHash, gc.Not(gc.Equals), compatHash)
c.Assert(afterHash, gc.Equals, utils.UserPasswordHash("foo", afterSalt))
// running PasswordValid again doesn't trigger another rewrite
c.Assert(user.PasswordValid("foo"), jc.IsTrue)
lastSalt, lastHash := state.GetUserPasswordSaltAndHash(user)
c.Assert(lastSalt, gc.Equals, afterSalt)
c.Assert(lastHash, gc.Equals, afterHash)
}
示例3: TestClientScript
func (*DebugHooksClientSuite) TestClientScript(c *gc.C) {
ctx := debug.NewHooksContext("foo/8")
// Test the variable substitutions.
result := debug.ClientScript(ctx, nil)
// No variables left behind.
c.Assert(result, gc.Not(gc.Matches), "(.|\n)*{unit_name}(.|\n)*")
c.Assert(result, gc.Not(gc.Matches), "(.|\n)*{tmux_conf}(.|\n)*")
c.Assert(result, gc.Not(gc.Matches), "(.|\n)*{entry_flock}(.|\n)*")
c.Assert(result, gc.Not(gc.Matches), "(.|\n)*{exit_flock}(.|\n)*")
// tmux new-session -d -s {unit_name}
c.Assert(result, gc.Matches, fmt.Sprintf("(.|\n)*tmux attach-session -t %s(.|\n)*", regexp.QuoteMeta(ctx.Unit)))
//) 9>{exit_flock}
c.Assert(result, gc.Matches, fmt.Sprintf("(.|\n)*\\) 9>%s(.|\n)*", regexp.QuoteMeta(ctx.ClientExitFileLock())))
//) 8>{entry_flock}
c.Assert(result, gc.Matches, fmt.Sprintf("(.|\n)*\\) 8>%s(.|\n)*", regexp.QuoteMeta(ctx.ClientFileLock())))
// nil is the same as empty slice is the same as "*".
// Also, if "*" is present as well as a named hook,
// it is equivalent to "*".
c.Assert(debug.ClientScript(ctx, nil), gc.Equals, debug.ClientScript(ctx, []string{}))
c.Assert(debug.ClientScript(ctx, []string{"*"}), gc.Equals, debug.ClientScript(ctx, nil))
c.Assert(debug.ClientScript(ctx, []string{"*", "something"}), gc.Equals, debug.ClientScript(ctx, []string{"*"}))
// debug.ClientScript does not validate hook names, as it doesn't have
// a full state API connection to determine valid relation hooks.
expected := fmt.Sprintf(
`(.|\n)*echo "aG9va3M6Ci0gc29tZXRoaW5nIHNvbWV0aGluZ2Vsc2UK" | base64 -d > %s(.|\n)*`,
regexp.QuoteMeta(ctx.ClientFileLock()),
)
c.Assert(debug.ClientScript(ctx, []string{"something somethingelse"}), gc.Matches, expected)
}
示例4: TestIsEmpty
func (s *ConstraintsSuite) TestIsEmpty(c *gc.C) {
con := constraints.Value{}
c.Check(&con, jc.Satisfies, constraints.IsEmpty)
con = constraints.MustParse("arch=amd64")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("")
c.Check(&con, jc.Satisfies, constraints.IsEmpty)
con = constraints.MustParse("tags=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("spaces=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("mem=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("arch=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("root-disk=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("cpu-power=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("cores=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("container=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
con = constraints.MustParse("instance-type=")
c.Check(&con, gc.Not(jc.Satisfies), constraints.IsEmpty)
}
示例5: TestParseNoTagsNoNetworks
func (s *ConstraintsSuite) TestParseNoTagsNoNetworks(c *gc.C) {
con := constraints.MustParse("arch=amd64 mem=4G cpu-cores=1 root-disk=8G tags= networks=")
c.Assert(con.Tags, gc.Not(gc.IsNil))
c.Assert(con.Networks, gc.Not(gc.IsNil))
c.Check(*con.Tags, gc.HasLen, 0)
c.Check(*con.Networks, gc.HasLen, 0)
}
示例6: TestUpdateEnvInfo
func (s *OpenSuite) TestUpdateEnvInfo(c *gc.C) {
store := jujuclienttesting.NewMemStore()
ctx := envtesting.BootstrapContext(c)
uuid := utils.MustNewUUID().String()
cfg, err := config.New(config.UseDefaults, map[string]interface{}{
"type": "dummy",
"name": "admin-model",
"uuid": uuid,
})
c.Assert(err, jc.ErrorIsNil)
controllerCfg := testing.FakeControllerConfig()
_, err = bootstrap.Prepare(ctx, store, bootstrap.PrepareParams{
ControllerConfig: controllerCfg,
ControllerName: "controller-name",
ModelConfig: cfg.AllAttrs(),
Cloud: dummy.SampleCloudSpec(),
AdminSecret: "admin-secret",
})
c.Assert(err, jc.ErrorIsNil)
foundController, err := store.ControllerByName("controller-name")
c.Assert(err, jc.ErrorIsNil)
c.Assert(foundController.ControllerUUID, gc.Not(gc.Equals), "")
c.Assert(foundController.CACert, gc.Not(gc.Equals), "")
foundModel, err := store.ModelByName("controller-name", "admin/admin-model")
c.Assert(err, jc.ErrorIsNil)
c.Assert(foundModel, jc.DeepEquals, &jujuclient.ModelDetails{
ModelUUID: cfg.UUID(),
})
}
示例7: TestUsingTCPRemote
func (s *configFunctionalSuite) TestUsingTCPRemote(c *gc.C) {
if s.client == nil {
c.Skip("LXD not running locally")
}
// We can't just pass the testingCert as part of the Local connection,
// because Validate() doesn't like Local remotes that have
// Certificates.
lxdclient.PatchGenerateCertificate(&s.CleanupSuite, testingCert, testingKey)
cfg := lxdclient.Config{
Namespace: "my-ns",
Remote: lxdclient.Local,
}
nonlocal, err := cfg.UsingTCPRemote()
c.Assert(err, jc.ErrorIsNil)
checkValidRemote(c, &nonlocal.Remote)
c.Check(nonlocal, jc.DeepEquals, lxdclient.Config{
Namespace: "my-ns",
Remote: lxdclient.Remote{
Name: lxdclient.Local.Name,
Host: nonlocal.Remote.Host,
Cert: nonlocal.Remote.Cert,
Protocol: lxdclient.LXDProtocol,
ServerPEMCert: nonlocal.Remote.ServerPEMCert,
},
})
c.Check(nonlocal.Remote.Host, gc.Not(gc.Equals), "")
c.Check(nonlocal.Remote.Cert.CertPEM, gc.Not(gc.Equals), "")
c.Check(nonlocal.Remote.Cert.KeyPEM, gc.Not(gc.Equals), "")
c.Check(nonlocal.Remote.ServerPEMCert, gc.Not(gc.Equals), "")
// TODO(ericsnow) Check that the server has the certs.
}
示例8: TestInsertQueryMatch
func (s *gonzoSuite) TestInsertQueryMatch(c *gc.C) {
for _, testCase := range queryMatchTestCases {
err := s.session.DB("db1").C("c1").Insert(testCase)
c.Assert(err, gc.IsNil)
}
var err error
var result []bson.M
err = s.session.DB("db1").C("c1").Find(bson.M{"artist": "ed hall"}).All(&result)
c.Assert(err, gc.IsNil)
c.Assert(result, gc.HasLen, 1)
err = s.session.DB("db1").C("c1").Find(bson.M{"label": "trance syndicate"}).All(&result)
c.Assert(err, gc.IsNil)
c.Assert(result, gc.HasLen, 2)
for i, m := range result {
c.Assert(m["label"], gc.Equals, "trance syndicate")
if i > 0 {
c.Assert(m["artist"], gc.Not(gc.DeepEquals), result[i-1]["artist"])
c.Assert(m["venue"], gc.Not(gc.DeepEquals), result[i-1]["venue"])
c.Assert(m["_id"], gc.Not(gc.DeepEquals), result[i-1]["_id"])
}
}
err = s.session.DB("db1").C("c1").Find(nil).All(&result)
c.Assert(err, gc.IsNil)
c.Assert(result, gc.HasLen, 3)
}
示例9: TestResolveMetadata
func (*metadataHelperSuite) TestResolveMetadata(c *gc.C) {
var versionStrings = []string{"1.2.3-precise-amd64"}
dir := c.MkDir()
toolstesting.MakeTools(c, dir, "released", versionStrings)
toolsList := coretools.List{{
Version: version.MustParseBinary(versionStrings[0]),
Size: 123,
SHA256: "abc",
}}
stor, err := filestorage.NewFileStorageReader(dir)
c.Assert(err, jc.ErrorIsNil)
err = tools.ResolveMetadata(stor, "released", nil)
c.Assert(err, jc.ErrorIsNil)
// We already have size/sha256, so ensure that storage isn't consulted.
countingStorage := &countingStorage{StorageReader: stor}
metadata := tools.MetadataFromTools(toolsList, "released")
err = tools.ResolveMetadata(countingStorage, "released", metadata)
c.Assert(err, jc.ErrorIsNil)
c.Assert(countingStorage.counter, gc.Equals, 0)
// Now clear size/sha256, and check that it is called, and
// the size/sha256 sum are updated.
metadata[0].Size = 0
metadata[0].SHA256 = ""
err = tools.ResolveMetadata(countingStorage, "released", metadata)
c.Assert(err, jc.ErrorIsNil)
c.Assert(countingStorage.counter, gc.Equals, 1)
c.Assert(metadata[0].Size, gc.Not(gc.Equals), 0)
c.Assert(metadata[0].SHA256, gc.Not(gc.Equals), "")
}
示例10: TestServiceStatus
func (s *serviceSuite) TestServiceStatus(c *gc.C) {
message := "a test message"
stat, err := s.wordpressService.Status()
c.Assert(err, jc.ErrorIsNil)
c.Assert(stat.Status, gc.Not(gc.Equals), status.Active)
c.Assert(stat.Message, gc.Not(gc.Equals), message)
now := time.Now()
sInfo := status.StatusInfo{
Status: status.Active,
Message: message,
Data: map[string]interface{}{},
Since: &now,
}
err = s.wordpressService.SetStatus(sInfo)
c.Check(err, jc.ErrorIsNil)
stat, err = s.wordpressService.Status()
c.Check(err, jc.ErrorIsNil)
c.Check(stat.Status, gc.Equals, status.Active)
c.Check(stat.Message, gc.Equals, message)
result, err := s.apiService.Status(s.wordpressUnit.Name())
c.Check(err, gc.ErrorMatches, `"wordpress/0" is not leader of "wordpress"`)
s.claimLeadership(c, s.wordpressUnit, s.wordpressService)
result, err = s.apiService.Status(s.wordpressUnit.Name())
c.Check(err, jc.ErrorIsNil)
c.Check(result.Application.Status, gc.Equals, status.Active.String())
}
示例11: TestClose
func (s *statePoolSuite) TestClose(c *gc.C) {
p := state.NewStatePool(s.State)
defer p.Close()
// Get some State instances.
st1, err := p.Get(s.ModelUUID1)
c.Assert(err, jc.ErrorIsNil)
st2, err := p.Get(s.ModelUUID1)
c.Assert(err, jc.ErrorIsNil)
// Now close them.
err = p.Close()
c.Assert(err, jc.ErrorIsNil)
// Confirm that controller State isn't closed.
_, err = s.State.Model()
c.Assert(err, jc.ErrorIsNil)
// Ensure that new ones are returned if further States are
// requested.
st1_, err := p.Get(s.ModelUUID1)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st1_, gc.Not(gc.Equals), st1)
st2_, err := p.Get(s.ModelUUID2)
c.Assert(err, jc.ErrorIsNil)
c.Assert(st2_, gc.Not(gc.Equals), st2)
}
示例12: TestBase
func (s *environSuite) TestBase(c *gc.C) {
baseConfig := newConfig(c, validAttrs().Merge(testing.Attrs{"name": "testname"}))
env, err := environs.New(environs.OpenParams{
Cloud: fakeCloudSpec(),
Config: baseConfig,
})
c.Assert(err, gc.IsNil)
cfg := env.Config()
c.Assert(cfg, gc.NotNil)
c.Check(cfg.Name(), gc.Equals, "testname")
c.Check(env.PrecheckInstance("", constraints.Value{}, ""), gc.IsNil)
hasRegion, ok := env.(simplestreams.HasRegion)
c.Check(ok, gc.Equals, true)
c.Assert(hasRegion, gc.NotNil)
cloudSpec, err := hasRegion.Region()
c.Assert(err, gc.IsNil)
c.Check(cloudSpec.Region, gc.Not(gc.Equals), "")
c.Check(cloudSpec.Endpoint, gc.Not(gc.Equals), "")
c.Check(env.OpenPorts(nil), gc.IsNil)
c.Check(env.ClosePorts(nil), gc.IsNil)
ports, err := env.Ports()
c.Assert(err, gc.IsNil)
c.Check(ports, gc.IsNil)
}
示例13: TestAddUserSetsSalt
func (s *UserSuite) TestAddUserSetsSalt(c *gc.C) {
user := s.Factory.MakeUser(c, &factory.UserParams{Password: "a-password"})
salt, hash := state.GetUserPasswordSaltAndHash(user)
c.Assert(hash, gc.Not(gc.Equals), "")
c.Assert(salt, gc.Not(gc.Equals), "")
c.Assert(utils.UserPasswordHash("a-password", salt), gc.Equals, hash)
c.Assert(user.PasswordValid("a-password"), jc.IsTrue)
}
示例14: TestParseNoTagsNoSpaces
func (s *ConstraintsSuite) TestParseNoTagsNoSpaces(c *gc.C) {
con := constraints.MustParse(
"arch=amd64 mem=4G cores=1 root-disk=8G tags= spaces=",
)
c.Assert(con.Tags, gc.Not(gc.IsNil))
c.Assert(con.Spaces, gc.Not(gc.IsNil))
c.Check(*con.Tags, gc.HasLen, 0)
c.Check(*con.Spaces, gc.HasLen, 0)
}
示例15: TestBootstrap
func (t *Tests) TestBootstrap(c *gc.C) {
credential := t.Credential
if credential.AuthType() == "" {
credential = cloud.NewEmptyCredential()
}
var regions []cloud.Region
if t.CloudRegion != "" {
regions = []cloud.Region{{
Name: t.CloudRegion,
Endpoint: t.CloudEndpoint,
}}
}
args := bootstrap.BootstrapParams{
ControllerConfig: coretesting.FakeControllerConfig(),
CloudName: t.TestConfig["type"].(string),
Cloud: cloud.Cloud{
Type: t.TestConfig["type"].(string),
AuthTypes: []cloud.AuthType{credential.AuthType()},
Regions: regions,
Endpoint: t.CloudEndpoint,
},
CloudRegion: t.CloudRegion,
CloudCredential: &credential,
CloudCredentialName: "credential",
AdminSecret: AdminSecret,
CAPrivateKey: coretesting.CAKey,
}
e := t.Prepare(c)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), e, args)
c.Assert(err, jc.ErrorIsNil)
controllerInstances, err := e.ControllerInstances(t.ControllerUUID)
c.Assert(err, jc.ErrorIsNil)
c.Assert(controllerInstances, gc.Not(gc.HasLen), 0)
e2 := t.Open(c, e.Config())
controllerInstances2, err := e2.ControllerInstances(t.ControllerUUID)
c.Assert(err, jc.ErrorIsNil)
c.Assert(controllerInstances2, gc.Not(gc.HasLen), 0)
c.Assert(controllerInstances2, jc.SameContents, controllerInstances)
err = environs.Destroy(e2.Config().Name(), e2, t.ControllerStore)
c.Assert(err, jc.ErrorIsNil)
// Prepare again because Destroy invalidates old environments.
e3 := t.Prepare(c)
err = bootstrap.Bootstrap(envtesting.BootstrapContext(c), e3, args)
c.Assert(err, jc.ErrorIsNil)
err = environs.Destroy(e3.Config().Name(), e3, t.ControllerStore)
c.Assert(err, jc.ErrorIsNil)
}