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


Golang Assertions.NoError方法代码示例

本文整理汇总了Golang中github.com/stretchr/testify/assert.Assertions.NoError方法的典型用法代码示例。如果您正苦于以下问题:Golang Assertions.NoError方法的具体用法?Golang Assertions.NoError怎么用?Golang Assertions.NoError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/stretchr/testify/assert.Assertions的用法示例。


在下文中一共展示了Assertions.NoError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: messagePartitionWriter

func messagePartitionWriter(a *assert.Assertions, store *messagePartition, n int, done chan bool) {
	for i := 1; i <= n; i++ {
		msg := []byte("Hello " + strconv.Itoa(i))
		a.NoError(store.Store(uint64(i), msg))
	}
	done <- true
}
开发者ID:smancke,项目名称:guble,代码行数:7,代码来源:message_partition_robustness_test.go

示例2: writeJSONToService

func writeJSONToService(service baseftrwapp.Service, pathToJSONFile string, assert *assert.Assertions) {
	f, err := os.Open(pathToJSONFile)
	assert.NoError(err)
	dec := json.NewDecoder(f)
	inst, _, errr := service.DecodeJSON(dec)
	assert.NoError(errr)
	errrr := service.Write(inst)
	assert.NoError(errrr)
}
开发者ID:Financial-Times,项目名称:public-organisations-api,代码行数:9,代码来源:cypher_test.go

示例3: writeJSONToService

func writeJSONToService(service annotations.Service, pathToJSONFile string, contentUUID string, assert *assert.Assertions) {
	f, err := os.Open(pathToJSONFile)
	assert.NoError(err)
	dec := json.NewDecoder(f)
	annotation, errr := service.DecodeJSON(dec)
	assert.NoError(errr)
	errrr := service.Write(contentUUID, annotation)
	assert.NoError(errrr)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:9,代码来源:service_concording_scenarios_test.go

示例4: getServices

func getServices(t *testing.T, assert *assert.Assertions, db neoutils.NeoConnection) (baseftrwapp.Service, baseftrwapp.Service, baseftrwapp.Service, baseftrwapp.Service, baseftrwapp.Service) {
	peopleRW := people.NewCypherPeopleService(db)
	assert.NoError(peopleRW.Initialise())
	organisationRW := organisations.NewCypherOrganisationService(db)
	assert.NoError(organisationRW.Initialise())
	membershipsRW := memberships.NewCypherMembershipService(db)
	assert.NoError(membershipsRW.Initialise())
	rolesRW := roles.NewCypherDriver(db)
	assert.NoError(rolesRW.Initialise())
	financialInstrumentsRW := financialinstruments.NewCypherFinancialInstrumentService(db)
	assert.NoError(financialInstrumentsRW.Initialise())
	return peopleRW, organisationRW, membershipsRW, rolesRW, financialInstrumentsRW
}
开发者ID:Financial-Times,项目名称:public-organisations-api,代码行数:13,代码来源:cypher_test.go

示例5: newTestableProvisioner

func newTestableProvisioner(assert *assert.Assertions, options volume.VolumeOptions) volume.Provisioner {
	tmpDir, err := utiltesting.MkTmpdir("flockervolumeTest")
	assert.NoError(err, fmt.Sprintf("can't make a temp dir: %v", err))

	plugMgr := volume.VolumePluginMgr{}
	plugMgr.InitPlugins(ProbeVolumePlugins(), volumetest.NewFakeVolumeHost(tmpDir, nil, nil))

	plug, err := plugMgr.FindPluginByName(pluginName)
	assert.NoError(err, "Can't find the plugin by name")

	provisioner, err := plug.(*flockerPlugin).newProvisionerInternal(options, &fakeFlockerUtil{})

	return provisioner
}
开发者ID:eljefedelrodeodeljefe,项目名称:kubernetes,代码行数:14,代码来源:flocker_volume_test.go

示例6: readDocument

func readDocument(a *assert.Assertions, file string) Document {

	var document Document

	out, err := ioutil.ReadFile(file)
	a.NoError(err)

	err = yaml.Unmarshal(out, &document.stack)
	a.NoError(err)
	a.NotEmpty(document.stack)

	return document

}
开发者ID:inka,项目名称:tacks,代码行数:14,代码来源:document_test.go

示例7: writeClassifedByRelationship

func writeClassifedByRelationship(db neoutils.NeoConnection, contentId string, conceptId string, lifecycle string, t *testing.T, assert *assert.Assertions) {
	var annotateQuery string
	var qs []*neoism.CypherQuery

	if lifecycle == "" {
		annotateQuery = `
                MERGE (content:Thing{uuid:{contentId}})
                MERGE (upp:Identifier:UPPIdentifier{value:{conceptId}})
                MERGE (upp)-[:IDENTIFIES]->(concept:Thing) ON CREATE SET concept.uuid = {conceptId}
                MERGE (content)-[pred:IS_CLASSIFIED_BY {platformVersion:'v1'}]->(concept)
          `
		qs = []*neoism.CypherQuery{
			{
				Statement:  annotateQuery,
				Parameters: neoism.Props{"contentId": contentId, "conceptId": conceptId},
			},
		}
	} else {
		annotateQuery = `
                MERGE (content:Thing{uuid:{contentId}})
                MERGE (upp:Identifier:UPPIdentifier{value:{conceptId}})
                MERGE (upp)-[:IDENTIFIES]->(concept:Thing) ON CREATE SET concept.uuid = {conceptId}
                MERGE (content)-[pred:IS_CLASSIFIED_BY {platformVersion:'v1', lifecycle: {lifecycle}}]->(concept)
          `
		qs = []*neoism.CypherQuery{
			{
				Statement:  annotateQuery,
				Parameters: neoism.Props{"contentId": contentId, "conceptId": conceptId, "lifecycle": lifecycle},
			},
		}

	}
	err := db.CypherBatch(qs)
	assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:content-rw-neo4j,代码行数:35,代码来源:content_service_test.go

示例8: assertMetrics

func assertMetrics(a *assert.Assertions, s *service.Service, expected expectedValues) {
	httpClient := &http.Client{}
	u := fmt.Sprintf("http://%s%s", s.WebServer().GetAddr(), defaultMetricsEndpoint)
	request, err := http.NewRequest(http.MethodGet, u, nil)
	a.NoError(err)

	response, err := httpClient.Do(request)
	a.NoError(err)
	defer response.Body.Close()

	a.Equal(http.StatusOK, response.StatusCode)
	bodyBytes, err := ioutil.ReadAll(response.Body)
	a.NoError(err)
	logger.WithField("body", string(bodyBytes)).Debug("metrics response")

	mFCM := &fcmMetrics{}
	err = json.Unmarshal(bodyBytes, mFCM)
	a.NoError(err)

	a.Equal(0, mFCM.TotalSentMessageErrors)
	a.Equal(expected.MessageCount, mFCM.TotalSentMessages)

	a.Equal(0, mFCM.Minute.CurrentErrorsCount)
	a.Equal(expected.MessageCount, mFCM.Minute.CurrentMessagesCount)
	a.Equal(0, mFCM.Minute.CurrentErrorsTotalLatencies)
	a.Equal(expected.ZeroLatencies, mFCM.Minute.CurrentMessagesTotalLatencies == 0)

	a.Equal(0, mFCM.Hour.CurrentErrorsCount)
	a.Equal(expected.MessageCount, mFCM.Hour.CurrentMessagesCount)
	a.Equal(0, mFCM.Hour.CurrentErrorsTotalLatencies)
	a.Equal(expected.ZeroLatencies, mFCM.Hour.CurrentMessagesTotalLatencies == 0)

	a.Equal(0, mFCM.Day.CurrentErrorsCount)
	a.Equal(expected.MessageCount, mFCM.Day.CurrentMessagesCount)
	a.Equal(0, mFCM.Day.CurrentErrorsTotalLatencies)
	a.Equal(expected.ZeroLatencies, mFCM.Day.CurrentMessagesTotalLatencies == 0)

	mRouter := &routerMetrics{}
	err = json.Unmarshal(bodyBytes, mRouter)
	a.NoError(err)

	a.Equal(expected.CurrentRoutes, mRouter.CurrentRoutes)
	a.Equal(expected.CurrentSubscriptions, mRouter.CurrentSubscriptions)
}
开发者ID:smancke,项目名称:guble,代码行数:44,代码来源:fcm_integration_test.go

示例9: cleanDB

func cleanDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions, uuidsToClean []string) {
	qs := []*neoism.CypherQuery{}

	for _, uuid := range uuidsToClean {
		qs = append(qs, &neoism.CypherQuery{Statement: fmt.Sprintf("MATCH (org:Thing {uuid: '%v'})<-[:IDENTIFIES*0..]-(i:Identifier) DETACH DELETE org, i", uuid)})
		qs = append(qs, &neoism.CypherQuery{Statement: fmt.Sprintf("MATCH (org:Thing {uuid: '%v'}) DETACH DELETE org", uuid)})
	}

	err := db.CypherBatch(qs)
	assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:11,代码来源:test_utils.go

示例10: getDatabaseConnection

func getDatabaseConnection(assert *assert.Assertions) neoutils.NeoConnection {
	url := os.Getenv("NEO4J_TEST_URL")
	if url == "" {
		url = "http://localhost:7474/db/data"
	}

	conf := neoutils.DefaultConnectionConfig()
	conf.Transactional = false
	db, err := neoutils.Connect(url, conf)
	assert.NoError(err, "Failed to connect to Neo4j")
	return db
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:12,代码来源:test_utils.go

示例11: testByteRange

func testByteRange(assert *assert.Assertions, offset, length int64, expect io.ReadSeeker, actual io.ReadSeeker) {
	n, err := expect.Seek(offset, 0)
	assert.Equal(offset, n)
	assert.NoError(err)

	b1 := &bytes.Buffer{}
	n, err = io.CopyN(b1, expect, length)
	assert.Equal(length, n)
	assert.NoError(err)

	n, err = actual.Seek(offset, 0)
	assert.Equal(offset, n)
	assert.NoError(err)

	b2 := &bytes.Buffer{}
	n, err = io.CopyN(b2, actual, length)
	assert.Equal(length, n)
	assert.NoError(err)

	assert.Equal(b1.Bytes(), b2.Bytes())
}
开发者ID:arv,项目名称:noms-old,代码行数:21,代码来源:compound_blob_test.go

示例12: cleanDB

func cleanDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions) {
	qs := []*neoism.CypherQuery{
		{
			Statement: fmt.Sprintf("MATCH (mc:Thing {uuid: '%v'}) DETACH DELETE mc", minimalContentUuid),
		},
		{
			Statement: fmt.Sprintf("MATCH (fc:Thing {uuid: '%v'}) DETACH DELETE fc", fullContentUuid),
		},
	}

	err := db.CypherBatch(qs)
	assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:content-rw-neo4j,代码行数:13,代码来源:content_service_test.go

示例13: cleanRelationshipDB

func cleanRelationshipDB(db neoutils.CypherRunner, t *testing.T, assert *assert.Assertions, uuidsToClean []string) {
	cleanDB(db, t, assert, uuidsToClean)

	qs := []*neoism.CypherQuery{
		{
			Statement: fmt.Sprintf("MATCH (c:Content {uuid: '%v'})-[rel]-(o) DELETE c, rel ", relationShipTransferContentUUID),
		},
		{
			Statement: fmt.Sprintf("MATCH (c:Content {uuid: '%v'}) DELETE c ", relationShipTransferContentUUID),
		},
	}

	err := db.CypherBatch(qs)
	assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:15,代码来源:relationship_transfer_test.go

示例14: mockGetStateNodes

func mockGetStateNodes(assert *assert.Assertions, data []byte) *Client {

	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		assert.Equal("GET", r.Method)
		assert.Equal("/v1/state/nodes", r.URL.Path)
		w.Write(data)
	}))

	host, port, err := getHostAndPortFromTestServer(ts)
	assert.NoError(err)

	c := newFlockerTestClient(host, port)

	return c
}
开发者ID:ClusterHQ,项目名称:flocker-go,代码行数:15,代码来源:client_test.go

示例15: deleteAllViaService

func deleteAllViaService(db neoutils.CypherRunner, assert *assert.Assertions, annotationsRW annotations.Service) {
	_, err := annotationsRW.Delete(contentUUID)
	assert.Nil(err)

	qs := []*neoism.CypherQuery{
		{
			Statement: fmt.Sprintf("MATCH (c:Thing {uuid: '%v'})-[rel]-(o) DELETE c, rel ", contentUUID),
		},
		{
			Statement: fmt.Sprintf("MATCH (c:Thing {uuid: '%v'}) DELETE c ", contentUUID),
		},
	}

	err = db.CypherBatch(qs)
	assert.NoError(err)
}
开发者ID:Financial-Times,项目名称:organisations-rw-neo4j,代码行数:16,代码来源:service_concording_scenarios_test.go


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