• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.NotRegexp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestGenerateModel_WithTuple

func TestGenerateModel_WithTuple(t *testing.T) {
	specDoc, err := spec.Load("../fixtures/codegen/todolist.models.yml")
	if assert.NoError(t, err) {
		definitions := specDoc.Spec().Definitions
		k := "WithTuple"
		schema := definitions[k]
		genModel, err := makeGenDefinition(k, "models", schema, specDoc)
		if assert.NoError(t, err) && assert.NotEmpty(t, genModel.ExtraSchemas) && assert.NotEmpty(t, genModel.Properties) {
			assert.False(t, genModel.IsTuple)
			assert.True(t, genModel.IsComplexObject)
			assert.False(t, genModel.IsArray)
			assert.False(t, genModel.IsAnonymous)

			sch := genModel.ExtraSchemas[0]
			assert.True(t, sch.IsTuple)
			assert.False(t, sch.IsComplexObject)
			assert.False(t, sch.IsArray)
			assert.False(t, sch.IsAnonymous)
			assert.Equal(t, k+"FlagsTuple0", sch.Name)
			assert.False(t, sch.HasAdditionalItems)
			assert.Nil(t, sch.AdditionalItems)

			prop := genModel.Properties[0]
			assert.False(t, genModel.IsTuple)
			assert.True(t, genModel.IsComplexObject)
			assert.False(t, prop.IsArray)
			assert.False(t, prop.IsAnonymous)
			assert.Equal(t, k+"FlagsTuple0", prop.GoType)
			assert.Equal(t, "flags", prop.Name)
			buf := bytes.NewBuffer(nil)
			err := modelTemplate.Execute(buf, genModel)
			if assert.NoError(t, err) {
				ff, err := formatGoFile("with_tuple.go", buf.Bytes())
				if assert.NoError(t, err) {
					res := string(ff)
					assertInCode(t, "swagger:model "+k+"Flags", res)
					assertInCode(t, "type "+k+"FlagsTuple0 struct {", res)
					assertInCode(t, "P0 int64 `json:\"-\"`", res)
					assertInCode(t, "P1 string `json:\"-\"`", res)
					assertInCode(t, k+"FlagsTuple0) UnmarshalJSON", res)
					assertInCode(t, k+"FlagsTuple0) MarshalJSON", res)
					assertInCode(t, "json.Marshal(data)", res)
					assert.NotRegexp(t, regexp.MustCompile("lastIndex"), res)

					for i, p := range sch.Properties {
						r := "m.P" + strconv.Itoa(i)
						if !p.IsNullable {
							r = "&" + r
						}
						assertInCode(t, "json.Unmarshal(stage1["+strconv.Itoa(i)+"], "+r+")", res)
						assertInCode(t, "P"+strconv.Itoa(i)+",", res)
					}
				}
			}
		}
	}
}
开发者ID:ChrisPRobinson,项目名称:go-swagger,代码行数:57,代码来源:model_test.go


示例2: TestRegexp

func TestRegexp(t *testing.T) {
	app := New("test", "")
	flag := app.Flag("reg", "").Regexp()
	_, err := app.Parse([]string{"--reg", "^abc$"})
	assert.NoError(t, err)
	assert.NotNil(t, *flag)
	assert.Equal(t, "^abc$", (*flag).String())
	assert.Regexp(t, *flag, "abc")
	assert.NotRegexp(t, *flag, "abcd")
}
开发者ID:freakmac,项目名称:adbfs,代码行数:10,代码来源:flags_test.go


示例3: TestGenerateModel_SimpleTuple

func TestGenerateModel_SimpleTuple(t *testing.T) {
	tt := templateTest{t, modelTemplate}
	specDoc, err := spec.Load("../fixtures/codegen/todolist.models.yml")
	if assert.NoError(t, err) {
		definitions := specDoc.Spec().Definitions
		k := "SimpleTuple"
		schema := definitions[k]
		genModel, err := makeGenDefinition(k, "models", schema, specDoc)
		if assert.NoError(t, err) && assert.Empty(t, genModel.ExtraSchemas) {
			assert.True(t, genModel.IsTuple)
			assert.False(t, genModel.IsComplexObject)
			assert.False(t, genModel.IsArray)
			assert.False(t, genModel.IsAnonymous)
			assert.Equal(t, k, genModel.Name)
			assert.Equal(t, k, genModel.GoType)
			assert.Len(t, genModel.Properties, 5)
			buf := bytes.NewBuffer(nil)
			tt.template.Execute(buf, genModel)
			res := buf.String()
			assertInCode(t, "swagger:model "+k, res)
			assertInCode(t, "type "+k+" struct {", res)
			assertInCode(t, "P0 int64 `json:\"-\"`", res)
			assertInCode(t, "P1 string `json:\"-\"`", res)
			assertInCode(t, "P2 strfmt.DateTime `json:\"-\"`", res)
			assertInCode(t, "P3 *Notable `json:\"-\"`", res)
			assertInCode(t, "P4 *Notable `json:\"-\"`", res)
			assertInCode(t, k+") UnmarshalJSON", res)
			assertInCode(t, k+") MarshalJSON", res)
			assertInCode(t, "json.Marshal(data)", res)
			assert.NotRegexp(t, regexp.MustCompile("lastIndex"), res)

			for i, p := range genModel.Properties {
				r := "m.P" + strconv.Itoa(i)
				if !p.IsNullable {
					r = "&" + r
				}
				assertInCode(t, "json.Unmarshal(stage1["+strconv.Itoa(i)+"], "+r+")", res)
				assertInCode(t, "P"+strconv.Itoa(i)+",", res)
			}
		}
	}
}
开发者ID:ChrisPRobinson,项目名称:go-swagger,代码行数:42,代码来源:model_test.go


示例4: NotRegexp

// NotRegexp asserts that a specified regexp does not match a string.
//
//  assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
//  assert.NotRegexp(t, "^start", "it's not starting")
//
// Returns whether the assertion was successful (true) or not (false).
func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) {
	if !assert.NotRegexp(t, rx, str, msgAndArgs...) {
		t.FailNow()
	}
}
开发者ID:stretchr,项目名称:testify,代码行数:11,代码来源:require.go


示例5: assertNotInCode

func assertNotInCode(t testing.TB, expr, code string) bool {
	return assert.NotRegexp(t, reqm(expr), code)
}
开发者ID:Cl0udPhish,项目名称:go-swagger,代码行数:3,代码来源:schemavalidation_test.go


示例6: NotRegexp

// NotRegexp asserts that a specified regexp does not match a string.
//
//  require.NotRegexp(t, regexp.MustCompile("starts"), "it's starting")
//  require.NotRegexp(t, "^start", "it's not starting")
func NotRegexp(t TestingT, rx interface{}, str interface{}) {
	if !assert.NotRegexp(t, rx, str) {
		t.FailNow()
	}
}
开发者ID:MohamedFAhmed,项目名称:heapster,代码行数:9,代码来源:requirements.go


示例7: Test_Submit

func Test_Submit(t *testing.T) {
	check := Check{
		Name:     "test_check",
		Bulk:     "true",
		Report:   "true",
		output:   "myoutput\n",
		err_msg:  "myerror\nsecondline",
		rc:       0,
		duration: time.Duration(42 * time.Second),
		latency:  time.Duration(24 * time.Millisecond),
	}
	cfg = &Config{
		Host: "test01.example.com",
	}

	output := check.test_submission(t, false, 1024)
	expect := regexp.MustCompile(fmt.Sprintf("STATE \\d+ test01.example.com:bmad:test_check 0 %s",
		"test_check completed successfully!"))
	assert.Regexp(t, expect, output, "bulk + report returns state")

	check.rc = 2
	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile(fmt.Sprintf("STATE \\d+ test01.example.com:bmad:test_check 2 %s",
		"myerror secondline"))
	assert.Regexp(t, expect, output, "bulk + report with non-ok state gets stderr")

	check.Report = "false"
	check.Bulk = "true"
	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile("STATE")
	assert.NotRegexp(t, expect, output, "bulk + noreport doesn't do state")

	check.Report = "true"
	check.Bulk = "false"
	output = check.test_submission(t, false, 1024)
	assert.NotRegexp(t, expect, output, "nobulk + report doesn't do state")

	output = check.test_submission(t, true, 1024)
	expect = regexp.MustCompile("^myoutput")
	assert.Regexp(t, expect, output, "normal check output is still present")
	expect = regexp.MustCompile("COUNTER \\d+ test01.example.com:bmad:checks")
	assert.Regexp(t, expect, output, "bmad check counter meta-stat is reported")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:latency 0.0240")
	assert.Regexp(t, expect, output, "bmad latency meta-stat is reported")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:exec-time 42.0000")
	assert.Regexp(t, expect, output, "bmad exec time meta-stat is reported")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:test_check:exec-time 42.000")
	assert.Regexp(t, expect, output, "bmad check exec time meta-stat is reported")

	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile("^myoutput")
	assert.Regexp(t, expect, output, "normal check output is still present")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:exec-time 42.0000")
	assert.Regexp(t, expect, output, "bmad exec time meta-stat is reported")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:test_check:exec-time 42.000")
	assert.Regexp(t, expect, output, "bmad check exec time meta-stat is reported")
	expect = regexp.MustCompile("COUNTER \\d+ test01.example.com:bmad:checks")
	assert.NotRegexp(t, expect, output, "bmad check counter meta-stat is not reported")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:latency 0.0240")
	assert.NotRegexp(t, expect, output, "bmad latency meta-stat is not reported")

	check.Bulk = "true"
	check.attempts = 1
	check.Retries = 3
	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile("^myoutput")
	assert.Regexp(t, expect, output, "Bulk check with fewer attempts than retries submits status")

	check.Bulk = "false"
	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile("^myoutput")
	assert.NotRegexp(t, expect, output, "Non-bulk check with fewer attempts than retries doesn't submit status")
	expect = regexp.MustCompile("SAMPLE \\d+ test01.example.com:bmad:exec-time 42.0000")
	assert.Regexp(t, expect, output, "meta-stats are reported despite attempts less than max retries")

	check.attempts = 3
	output = check.test_submission(t, false, 1024)
	expect = regexp.MustCompile("^myoutput")
	assert.Regexp(t, expect, output, "Non-bulk check with more attempts than retries submits status")
}
开发者ID:qanx,项目名称:bmad,代码行数:80,代码来源:checks_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.NotZero函数代码示例发布时间:2022-05-28
下一篇:
Golang assert.NotPanics函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap