本文整理汇总了Golang中github.com/stretchr/testify/require.NotEqual函数的典型用法代码示例。如果您正苦于以下问题:Golang NotEqual函数的具体用法?Golang NotEqual怎么用?Golang NotEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NotEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAbsPath
func TestAbsPath(t *testing.T) {
// should expand path
currDirPath, err := filepath.Abs(".")
require.Equal(t, nil, err)
require.NotEqual(t, "", currDirPath)
require.NotEqual(t, ".", currDirPath)
homePathEnv := "/path/home/test-user"
require.Equal(t, nil, os.Setenv("HOME", homePathEnv))
testFileRelPathFromHome := "some/file.ext"
absPathToTestFile := fmt.Sprintf("%s/%s", homePathEnv, testFileRelPathFromHome)
expandedPath, err := AbsPath("")
require.NotEqual(t, nil, err)
require.Equal(t, "", expandedPath)
expandedPath, err = AbsPath(".")
require.Equal(t, nil, err)
require.Equal(t, currDirPath, expandedPath)
expandedPath, err = AbsPath(fmt.Sprintf("$HOME/%s", testFileRelPathFromHome))
require.Equal(t, nil, err)
require.Equal(t, absPathToTestFile, expandedPath)
expandedPath, err = AbsPath(fmt.Sprintf("~/%s", testFileRelPathFromHome))
require.Equal(t, nil, err)
require.Equal(t, absPathToTestFile, expandedPath)
}
开发者ID:bitrise-io,项目名称:go-utils,代码行数:30,代码来源:pathutil_test.go
示例2: TestValidate
func TestValidate(t *testing.T) {
// No key-value
env := EnvironmentItemModel{
OptionsKey: EnvironmentItemOptionsModel{
Title: pointers.NewStringPtr("test_title"),
Description: pointers.NewStringPtr("test_description"),
Summary: pointers.NewStringPtr("test_summary"),
ValueOptions: []string{"test_key2", "test_value2"},
IsRequired: pointers.NewBoolPtr(true),
IsExpand: pointers.NewBoolPtr(true),
IsDontChangeValue: pointers.NewBoolPtr(false),
},
}
require.NotEqual(t, nil, env.Validate())
// Empty key
env = EnvironmentItemModel{
"": "test_value",
}
require.NotEqual(t, nil, env.Validate())
// Valid env
env = EnvironmentItemModel{
"test_key": "test_value",
}
require.Equal(t, nil, env.Validate())
}
开发者ID:fbernardo,项目名称:envman,代码行数:27,代码来源:models_methods_test.go
示例3: TestParseMutationAndQuery
func TestParseMutationAndQuery(t *testing.T) {
query := `
mutation {
set {
<name> <is> <something> .
<hometown> <is> <san francisco> .
}
delete {
<name> <is> <something-else> .
}
}
query {
me(_xid_: tomhanks) {
name
hometown
}
}
`
gq, mu, err := Parse(query)
require.NoError(t, err)
require.NotNil(t, mu)
require.NotEqual(t, strings.Index(mu.Set, "<name> <is> <something> ."), -1)
require.NotEqual(t, strings.Index(mu.Set, "<hometown> <is> <san francisco> ."), -1)
require.NotEqual(t, strings.Index(mu.Del, "<name> <is> <something-else> ."), -1)
require.NotNil(t, gq)
require.Equal(t, gq.XID, "tomhanks")
require.Equal(t, childAttrs(gq), []string{"name", "hometown"})
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:29,代码来源:parser_test.go
示例4: TestBumpVersion
func TestBumpVersion(t *testing.T) {
version, err := bumpedVersion("", 0)
require.NotEqual(t, nil, err)
require.Equal(t, "", version)
version, err = bumpedVersion("-1", 0)
require.NotEqual(t, nil, err)
require.Equal(t, "", version)
version, err = bumpedVersion("1", 0)
require.Equal(t, nil, err)
require.Equal(t, "2.0.0", version)
version, err = bumpedVersion("1.1", 0)
require.Equal(t, nil, err)
require.Equal(t, "2.1.0", version)
version, err = bumpedVersion("1.1", 1)
require.Equal(t, nil, err)
require.Equal(t, "1.2.0", version)
version, err = bumpedVersion("1.1.1", 0)
require.Equal(t, nil, err)
require.Equal(t, "2.1.1", version)
version, err = bumpedVersion("1.1.1", 1)
require.Equal(t, nil, err)
require.Equal(t, "1.2.1", version)
version, err = bumpedVersion("1.1.1", 2)
require.Equal(t, nil, err)
require.Equal(t, "1.1.2", version)
}
开发者ID:bitrise-tools,项目名称:releaseman,代码行数:33,代码来源:utility_test.go
示例5: TestCreateKeyCreatesNewKeys
func TestCreateKeyCreatesNewKeys(t *testing.T) {
publicKey1, err := kmClient.CreateKey(context.Background(), &pb.Algorithm{Algorithm: data.ED25519Key})
require.Nil(t, err)
publicKey2, err := kmClient.CreateKey(context.Background(), &pb.Algorithm{Algorithm: data.ED25519Key})
require.Nil(t, err)
require.NotEqual(t, publicKey1, publicKey2)
require.NotEqual(t, publicKey1.KeyInfo, publicKey2.KeyInfo)
require.NotEqual(t, publicKey1.PublicKey, publicKey2.PublicKey)
}
开发者ID:mbentley,项目名称:notary,代码行数:9,代码来源:rpc_api_test.go
示例6: verifyGetResponse
// Verifies that the body is as expected and that there are cache control headers
func verifyGetResponse(t *testing.T, r *http.Response, expectedBytes []byte) {
body, err := ioutil.ReadAll(r.Body)
require.NoError(t, err)
require.True(t, bytes.Equal(expectedBytes, body))
require.NotEqual(t, "", r.Header.Get("Cache-Control"))
require.NotEqual(t, "", r.Header.Get("Last-Modified"))
require.Equal(t, "", r.Header.Get("Pragma"))
}
开发者ID:jfrazelle,项目名称:notary,代码行数:10,代码来源:server_test.go
示例7: TestRotateWithCompression
func TestRotateWithCompression(t *testing.T) {
f, err := ioutil.TempFile(os.TempDir(), "logr")
require.Nil(t, err)
rw, err := logr.NewWriterFromFileWithCompression(f)
require.Nil(t, err)
// add some clear text at the beginning of the file
text := []byte("This is some clear test at the beginning of the file.")
now := time.Now()
{
n, err := rw.Write(text)
require.Nil(t, err)
require.Equal(t, len(text), n)
n, err = rw.Write(makeBuf(0xFF))
require.Nil(t, err)
require.Equal(t, 1024, n)
rw.MaxSize(512)
n, err = rw.Write(makeBuf(0xFE))
require.Nil(t, err)
require.Equal(t, 1024, n)
}
newData := readFile(t, f.Name())
require.Nil(t, checkEqual(t, newData, 0xFE))
{
f, err := os.Open(f.Name() + "." + now.Format(logr.TimeFormat) + ".gz")
require.Nil(t, err)
require.NotNil(t, f)
rotatedDataGz, err := ioutil.ReadAll(f)
require.Nil(t, err)
require.NotEqual(t, 0, len(rotatedDataGz))
// should not be equal cause it has been gzipped
require.NotEqual(t, text, rotatedDataGz[:len(text)])
// gunzip
r, err := gzip.NewReader(bytes.NewReader(rotatedDataGz))
require.Nil(t, err)
gunzip, err := ioutil.ReadAll(r)
require.Nil(t, err)
// should be equal cause now gunzipped
require.Equal(t, text, gunzip[:len(text)])
}
}
开发者ID:remeh,项目名称:logr,代码行数:53,代码来源:logr_test.go
示例8: TestStepmanJSONStepLibStepInfo
func TestStepmanJSONStepLibStepInfo(t *testing.T) {
// Valid params -- Err should empty, output filled
require.Equal(t, nil, StepmanSetup("https://github.com/bitrise-io/bitrise-steplib"))
outStr, err := StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "0.9.0")
require.Equal(t, nil, err)
require.NotEqual(t, "", outStr)
// Invalid params -- Err should empty, output filled
outStr, err = StepmanJSONStepLibStepInfo("https://github.com/bitrise-io/bitrise-steplib", "script", "2")
require.NotEqual(t, nil, err)
require.Equal(t, "", outStr)
}
开发者ID:birmacher,项目名称:bitrise,代码行数:13,代码来源:run_test.go
示例9: TestMarshalEncoder
func TestMarshalEncoder(t *testing.T) {
record := newLogFFRecord()
out := bytes.Buffer{}
enc := ffjson.NewEncoder(&out)
err := enc.Encode(record)
require.NoError(t, err)
require.NotEqual(t, 0, out.Len(), "encoded buffer size should not be 0")
out.Reset()
err = enc.EncodeFast(record)
require.NoError(t, err)
require.NotEqual(t, 0, out.Len(), "encoded buffer size should not be 0")
}
开发者ID:gooops,项目名称:ffjson,代码行数:13,代码来源:ff_test.go
示例10: TestSwizzlerChangeRootKey
// This changes the root key
func TestSwizzlerChangeRootKey(t *testing.T) {
f, origMeta := createNewSwizzler(t)
f.ChangeRootKey()
tufRepo := tuf.NewRepo(f.CryptoService)
// we want to test these in a specific order
roles := []string{data.CanonicalRootRole, data.CanonicalTargetsRole, data.CanonicalSnapshotRole,
data.CanonicalTimestampRole, "targets/a", "targets/a/b"}
for _, role := range roles {
origMeta := origMeta[role]
newMeta, err := f.MetadataCache.GetMeta(role, -1)
require.NoError(t, err)
// the threshold for base roles is set in root
switch role {
case data.CanonicalRootRole:
require.False(t, bytes.Equal(origMeta, newMeta))
origRoot, newRoot := &data.SignedRoot{}, &data.SignedRoot{}
require.NoError(t, json.Unmarshal(origMeta, origRoot))
require.NoError(t, json.Unmarshal(newMeta, newRoot))
require.NotEqual(t, len(origRoot.Signed.Keys), len(newRoot.Signed.Keys))
var rootRole data.Role
for r, origRole := range origRoot.Signed.Roles {
newRole := newRoot.Signed.Roles[r]
require.Len(t, origRole.KeyIDs, 1)
require.Len(t, newRole.KeyIDs, 1)
if r == data.CanonicalRootRole {
require.NotEqual(t, origRole.KeyIDs[0], newRole.KeyIDs[0])
rootRole = data.Role{RootRole: *newRole, Name: data.CanonicalRootRole}
} else {
require.Equal(t, origRole.KeyIDs[0], newRole.KeyIDs[0])
}
}
require.NoError(t, tufRepo.SetRoot(newRoot))
signedThing, err := newRoot.ToSigned()
require.NoError(t, err)
newKey := newRoot.Signed.Keys[rootRole.KeyIDs[0]]
require.NoError(t, signed.Verify(signedThing,
data.BaseRole{Name: data.CanonicalRootRole, Keys: map[string]data.PublicKey{newKey.ID(): newKey}, Threshold: 1}, 1))
default:
require.True(t, bytes.Equal(origMeta, newMeta), "bytes have changed for role %s", role)
}
}
}
开发者ID:moxiegirl,项目名称:notary,代码行数:51,代码来源:swizzler_test.go
示例11: TestShortIDPropagation
func TestShortIDPropagation(t *testing.T) {
_, peers1 := newNode(PeerName(1))
_, peers2 := newNode(PeerName(2))
peers1.AddTestConnection(peers2.ourself.Peer)
peers1.applyUpdate(peers2.encodePeers(peers2.names()))
peers12 := peers1.Fetch(PeerName(2))
old := peers12.peerSummary
require.True(t,
peers2.reassignLocalShortID(&peersPendingNotifications{}))
peers1.applyUpdate(peers2.encodePeers(peers2.names()))
require.NotEqual(t, old.Version, peers12.Version)
require.NotEqual(t, old.ShortID, peers12.ShortID)
}
开发者ID:weaveworks,项目名称:mesh,代码行数:15,代码来源:peers_test.go
示例12: GetTileStoreFromEnv
// GetTileStoreFromEnv looks at the TEST_TILE_DIR environement variable for the
// name of directory that contains tiles. If it's defined it will return a
// TileStore instance. If the not the calling test will fail.
func GetTileStoreFromEnv(t assert.TestingT) tiling.TileStore {
// Get the TEST_TILE environment variable that points to the
// tile to read.
tileDir := os.Getenv("TEST_TILE_DIR")
assert.NotEqual(t, "", tileDir, "Please define the TEST_TILE_DIR environment variable to point to a live tile store.")
return filetilestore.NewFileTileStore(tileDir, config.DATASET_GOLD, 2*time.Minute)
}
开发者ID:1394,项目名称:skia-buildbot,代码行数:10,代码来源:mocks.go
示例13: deleteBad
func deleteBad(t *testing.T, ctx *Context) {
fmt.Println("deleteBad")
require.NotEqual(t, ctx.mountPath, "", "Device is not mounted")
err := ctx.Delete(ctx.volID)
require.Error(t, err, "Delete on mounted device must fail")
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:7,代码来源:driver.go
示例14: TestSwizzlerRotateKeyBaseRole
// This rotates the key of some base role
func TestSwizzlerRotateKeyBaseRole(t *testing.T) {
f, origMeta := createNewSwizzler(t)
theRole := data.CanonicalSnapshotRole
cs := signed.NewEd25519()
pubKey, err := cs.Create(theRole, f.Gun, data.ED25519Key)
require.NoError(t, err)
require.NoError(t, f.RotateKey(theRole, pubKey))
for role, metaBytes := range origMeta {
newMeta, err := f.MetadataCache.GetSized(role, store.NoSizeLimit)
require.NoError(t, err)
if role != data.CanonicalRootRole {
require.True(t, bytes.Equal(metaBytes, newMeta), "bytes have changed for role %s", role)
} else {
require.False(t, bytes.Equal(metaBytes, newMeta))
origSigned, newSigned := &data.SignedRoot{}, &data.SignedRoot{}
require.NoError(t, json.Unmarshal(metaBytes, origSigned))
require.NoError(t, json.Unmarshal(newMeta, newSigned))
require.NotEqual(t, []string{pubKey.ID()}, origSigned.Signed.Roles[theRole].KeyIDs)
require.Equal(t, []string{pubKey.ID()}, newSigned.Signed.Roles[theRole].KeyIDs)
_, ok := origSigned.Signed.Keys[pubKey.ID()]
require.False(t, ok)
_, ok = newSigned.Signed.Keys[pubKey.ID()]
require.True(t, ok)
}
}
}
开发者ID:jfrazelle,项目名称:notary,代码行数:31,代码来源:swizzler_test.go
示例15: TestNewLexerMutation
func TestNewLexerMutation(t *testing.T) {
input := `
mutation {
set {
What is <this> .
Why is this #!!?
How is this?
}
delete {
Why is this
}
}
query {
me(_xid_: rick) {
_city
}
}`
l := &lex.Lexer{}
l.Init(input)
go run(l)
for item := range l.Items {
require.NotEqual(t, item.Typ, lex.ItemError)
t.Log(item.String())
}
}
开发者ID:dgraph-io,项目名称:dgraph,代码行数:25,代码来源:state_test.go
示例16: TestNACLSecretbox
// Using the same key to encrypt the same message, this encrypter produces two
// different ciphertexts because it produces two different nonces. Both
// of these can be decrypted into the same data though.
func TestNACLSecretbox(t *testing.T) {
key := make([]byte, 32)
_, err := io.ReadFull(rand.Reader, key)
require.NoError(t, err)
crypter := NewNACLSecretbox(key)
data := []byte("Hello again world")
er1, err := crypter.Encrypt(data)
require.NoError(t, err)
er2, err := crypter.Encrypt(data)
require.NoError(t, err)
require.NotEqual(t, er1.Data, er2.Data)
require.NotEmpty(t, er1.Nonce, er2.Nonce)
result, err := crypter.Decrypt(*er1)
require.NoError(t, err)
require.Equal(t, data, result)
result, err = crypter.Decrypt(*er2)
require.NoError(t, err)
require.Equal(t, data, result)
}
开发者ID:docker,项目名称:swarmkit,代码行数:28,代码来源:nacl_test.go
示例17: assertExchange
// Perform a DNS query and assert the reply code, number or answers, etc
func assertExchange(t *testing.T, z string, ty uint16, port int, minAnswers int, maxAnswers int, expErr int) (*dns.Msg, *dns.Msg) {
require.NotEqual(t, 0, port, "invalid DNS server port")
c := &dns.Client{
UDPSize: testUDPBufSize,
}
m := new(dns.Msg)
m.RecursionDesired = true
m.SetQuestion(z, ty)
m.SetEdns0(testUDPBufSize, false) // we don't want to play with truncation here...
lstAddr := fmt.Sprintf("127.0.0.1:%d", port)
r, _, err := c.Exchange(m, lstAddr)
t.Logf("Response from '%s':\n%+v\n", lstAddr, r)
if err != nil {
t.Errorf("Error when querying DNS server at %s: %s", lstAddr, err)
}
require.NoError(t, err)
if minAnswers == 0 && maxAnswers == 0 {
require.Equal(t, expErr, r.Rcode, "DNS response code")
} else {
require.Equal(t, dns.RcodeSuccess, r.Rcode, "DNS response code")
}
answers := len(r.Answer)
if minAnswers >= 0 && answers < minAnswers {
require.FailNow(t, fmt.Sprintf("Number of answers >= %d", minAnswers))
}
if maxAnswers >= 0 && answers > maxAnswers {
require.FailNow(t, fmt.Sprintf("Number of answers <= %d", maxAnswers))
}
return m, r
}
开发者ID:rahulxkrishna,项目名称:weave,代码行数:34,代码来源:mocks_test.go
示例18: testStoreFeatures
func testStoreFeatures(t *testing.T, store Store) {
// it should failt to get a feature that doesn't exist
found, err := store.GetFeatureByName("awesome_feature")
require.Equal(t, ErrNoRows, err)
// it should get an empty list when there is no features
list, err := store.ListFeatures()
require.NoError(t, err)
require.Empty(t, list)
// it should create a feature
feature := &models.Feature{
Name: "awesome_feature",
}
err = store.CreateFeature(feature)
require.NoError(t, err)
require.NotEqual(t, feature.ID, 0)
require.Equal(t, "awesome_feature", feature.Name)
require.Empty(t, feature.Status)
// it should update a feature
feature.Name = "not_awesome_feature"
err = store.UpdateFeature(feature)
require.NoError(t, err)
// it should list all features
list, err = store.ListFeatures()
require.NoError(t, err)
require.Len(t, list, 1)
// it should get a feature with the status of all environments
err = store.CreateEnvironment(&models.Environment{
Name: "staging",
})
require.NoError(t, err)
found, err = store.GetFeatureByName("not_awesome_feature")
require.NoError(t, err)
require.Len(t, found.Status, 1)
require.Equal(t, false, found.Status["staging"])
// it should update the status of a feature in an environment
found.Status["staging"] = true
err = store.UpdateFeature(found)
require.NoError(t, err)
found, err = store.GetFeatureByName("not_awesome_feature")
require.NoError(t, err)
require.Equal(t, true, found.Status["staging"])
// it should list all features with the status on all environments
list, err = store.ListFeatures()
require.NoError(t, err)
require.Len(t, list, 1)
require.Equal(t, found.ID, list[0].ID)
require.True(t, list[0].Status["staging"])
}
开发者ID:MEDIGO,项目名称:laika,代码行数:60,代码来源:store_test.go
示例19: TestLockFileReadAndUnlockFile
func TestLockFileReadAndUnlockFile(t *testing.T) {
// Create a temporary file
tmpDir, err := ioutil.TempDir("", "TestLockFileReadAndUnlockFile")
defer os.RemoveAll(tmpDir)
require.Nil(t, err)
require.NotEqual(t, "", tmpDir)
// Create the dummy file, and open it for reading
file1 := filepath.Join(tmpDir, "file1")
ioutil.WriteFile(file1, []byte("123"), 0700)
file, err := os.Open(file1)
require.Nil(t, err)
// We opened the file read-only, so trying to get a write lock should result in an error
assert.NotNil(t, LockFile(file, Write))
// Get the read lock
assert.Nil(t, LockFile(file, Read))
// Make sure that we hold a proper lock to the file
locked, err := isLocked(file1, "READ")
assert.Nil(t, err)
assert.True(t, locked)
// // Unlock the file again
assert.Nil(t, UnlockFile(file))
// Make sure that we no longer hold the lock
locked, err = isLocked(file1, "READ")
assert.Nil(t, err)
assert.False(t, locked)
file.Close()
}
开发者ID:pw1,项目名称:fsutil,代码行数:34,代码来源:locking_test.go
示例20: TestSwizzlerRotateKeyDelegationRole
// This rotates the key of some delegation role
func TestSwizzlerRotateKeyDelegationRole(t *testing.T) {
f, origMeta := createNewSwizzler(t)
theRole := "targets/a/b"
cs := signed.NewEd25519()
pubKey, err := cs.Create(theRole, f.Gun, data.ED25519Key)
require.NoError(t, err)
require.NoError(t, f.RotateKey(theRole, pubKey))
for role, metaBytes := range origMeta {
newMeta, err := f.MetadataCache.GetMeta(role, store.NoSizeLimit)
require.NoError(t, err)
if role != "targets/a" {
require.True(t, bytes.Equal(metaBytes, newMeta), "bytes have changed for role %s", role)
} else {
require.False(t, bytes.Equal(metaBytes, newMeta))
origSigned, newSigned := &data.SignedTargets{}, &data.SignedTargets{}
require.NoError(t, json.Unmarshal(metaBytes, origSigned))
require.NoError(t, json.Unmarshal(newMeta, newSigned))
require.NotEqual(t, []string{pubKey.ID()}, origSigned.Signed.Delegations.Roles[0].KeyIDs)
require.Equal(t, []string{pubKey.ID()}, newSigned.Signed.Delegations.Roles[0].KeyIDs)
_, ok := origSigned.Signed.Delegations.Keys[pubKey.ID()]
require.False(t, ok)
_, ok = newSigned.Signed.Delegations.Keys[pubKey.ID()]
require.True(t, ok)
}
}
}
开发者ID:mbentley,项目名称:notary,代码行数:31,代码来源:swizzler_test.go
注:本文中的github.com/stretchr/testify/require.NotEqual函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论