当前位置: 首页>>代码示例>>Golang>>正文


Golang require.NotEqual函数代码示例

本文整理汇总了Golang中github.com/stretchr/testify/require.NotEqual函数的典型用法代码示例。如果您正苦于以下问题:Golang NotEqual函数的具体用法?Golang NotEqual怎么用?Golang NotEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NotEqual函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的github.com/stretchr/testify/require.NotEqual函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。