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

Golang util.CreateFileIn函数代码示例

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

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



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

示例1: TestInitConceptsCache

func (s *MySuite) TestInitConceptsCache(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "concept1.cpt", concept1)
	c.Assert(err, Equals, nil)
	_, err = util.CreateFileIn(s.specsDir, "concept2.cpt", concept2)
	c.Assert(err, Equals, nil)
	specInfoGatherer := new(SpecInfoGatherer)

	specInfoGatherer.initConceptsCache()

	c.Assert(len(specInfoGatherer.conceptsCache), Equals, 2)
}
开发者ID:adiferd,项目名称:gauge,代码行数:11,代码来源:specDetails_test.go


示例2: TestRemovingConcepts

func (s *MySuite) TestRemovingConcepts(c *C) {
	data := []byte(`# A concept
* first step with "foo"
* second say "hello" to me
* third "foo" step

# second concept
* fourth
* fifth step
* third concept
`)

	data1 := []byte(`# third concept
* second say "hello" to me
* A concept

# fourth concept with <a>
* sixth step with <a>
* seventh "param" step
`)

	util.CreateFileIn(s.specsDir, "concept.cpt", data)
	util.CreateFileIn(s.specsDir, "concept1.cpt", data1)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromConcepts()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 2)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 7)
	c.Assert(len(specInfoGatherer.getConceptInfos()), Equals, 4)

	firstCptFile := filepath.Join(s.specsDir, "concept.cpt")
	os.Remove(firstCptFile)
	specInfoGatherer.removeConcept(firstCptFile)

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)
	allSteps = specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 4)

	stepValues := make([]string, 0)
	for _, stepValue := range allSteps {
		stepValues = append(stepValues, stepValue.stepValue)
	}

	c.Assert(stringInSlice("second say {} to me", stepValues), Equals, true)
	c.Assert(stringInSlice("A concept", stepValues), Equals, true)
	c.Assert(stringInSlice("sixth step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("seventh {} step", stepValues), Equals, true)

	cptInfos := specInfoGatherer.getConceptInfos()
	c.Assert(len(cptInfos), Equals, 2)
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:54,代码来源:specDetails_test.go


示例3: TestInitConceptsCache

func (s *MySuite) TestInitConceptsCache(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "concept1.cpt", concept1)
	c.Assert(err, Equals, nil)
	_, err = util.CreateFileIn(s.specsDir, "concept2.cpt", concept2)
	c.Assert(err, Equals, nil)
	specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.projectDir + string(filepath.Separator) + specDir}}
	specInfoGatherer.waitGroup.Add(1)

	specInfoGatherer.initConceptsCache()

	c.Assert(len(specInfoGatherer.conceptsCache), Equals, 2)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:12,代码来源:specDetails_test.go


示例4: TestAddSpec

func (s *MySuite) TestAddSpec(c *C) {
	data := []byte(`Specification Heading
=====================
Scenario 1
----------
* first step with "foo"
* say "hello" to me
* a "final" step
`)
	data1 := []byte(`Specification Heading2
=====================
Scenario 1
----------
* say hello to gauge
* testing steps with "params"
* last step
`)

	util.CreateFileIn(s.specsDir, "Spec1.spec", data)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromSpecs()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 1)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 3)

	util.CreateFileIn(s.specsDir, "Spec2.spec", data1)
	specInfoGatherer.addSpec(filepath.Join(s.specsDir, "Spec2.spec"))
	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 2)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 2)

	allSteps = specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 6)

	stepValues := make([]string, 0)
	for _, stepValue := range allSteps {
		stepValues = append(stepValues, stepValue.stepValue)
	}

	c.Assert(stringInSlice("first step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("say {} to me", stepValues), Equals, true)
	c.Assert(stringInSlice("a {} step", stepValues), Equals, true)
	c.Assert(stringInSlice("say hello to gauge", stepValues), Equals, true)
	c.Assert(stringInSlice("testing steps with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("last step", stepValues), Equals, true)
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:49,代码来源:specDetails_test.go


示例5: TestRemoveSpec

func (s *MySuite) TestRemoveSpec(c *C) {
	data := []byte(`Specification Heading
=====================
Scenario 1
----------
* say hello
* say "hello" to me
`)
	data1 := []byte(`Specification Heading2
=====================
Scenario 1
----------
* say hello 1
* say "hello" to me 1
`)

	specFile1, err := util.CreateFileIn(s.specsDir, "Spec1.spec", data)
	specFile2, err := util.CreateFileIn(s.specsDir, "Spec2.spec", data1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromSpecs()
	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 2)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 2)

	steps, ok := specInfoGatherer.fileToStepsMap[specFile1]
	c.Assert(ok, Equals, true)
	c.Assert(len(steps), Equals, 2)
	c.Assert(steps[0].lineText, Equals, "say hello")
	c.Assert(steps[1].lineText, Equals, "say \"hello\" to me")

	steps, ok = specInfoGatherer.fileToStepsMap[specFile2]
	c.Assert(ok, Equals, true)
	c.Assert(len(steps), Equals, 2)
	c.Assert(steps[0].lineText, Equals, "say hello 1")
	c.Assert(steps[1].lineText, Equals, "say \"hello\" to me 1")

	specInfoGatherer.removeSpec(filepath.Join(s.specsDir, "Spec1.spec"))

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 2)

	steps, ok = specInfoGatherer.fileToStepsMap[specFile2]
	c.Assert(ok, Equals, true)

	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 2)
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:48,代码来源:specDetails_test.go


示例6: TestRemoveSpecWithCommonSteps

func (s *MySuite) TestRemoveSpecWithCommonSteps(c *C) {
	data := []byte(`Specification Heading
=====================
Scenario 1
----------
* say hello
* say "hello" to me
* a common step
`)
	data1 := []byte(`Specification Heading2
=====================
Scenario 1
----------
* say hello 1
* say "hello" to me 1
* a common step
`)

	util.CreateFileIn(s.specsDir, "Spec1.spec", data)
	util.CreateFileIn(s.specsDir, "Spec2.spec", data1)

	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromSpecs()
	specInfoGatherer.updateAllStepsList()
	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 2)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 2)

	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 5)

	specInfoGatherer.removeSpec(filepath.Join(s.specsDir, "Spec1.spec"))

	allSteps = specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 3)

	stepValues := make([]string, 0)
	for _, stepValue := range allSteps {
		stepValues = append(stepValues, stepValue.stepValue)
	}

	c.Assert(stringInSlice("say hello 1", stepValues), Equals, true)
	c.Assert(stringInSlice("say {} to me 1", stepValues), Equals, true)
	c.Assert(stringInSlice("a common step", stepValues), Equals, true)
	c.Assert(stringInSlice("say hello", stepValues), Equals, false)
	c.Assert(stringInSlice("say {} to me", stepValues), Equals, false)

}
开发者ID:Jayasagar,项目名称:gauge,代码行数:48,代码来源:specDetails_test.go


示例7: TestInitSpecsCache

func (s *MySuite) TestInitSpecsCache(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "spec1.spec", spec1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := new(SpecInfoGatherer)

	specInfoGatherer.initSpecsCache()

	c.Assert(len(specInfoGatherer.specsCache), Equals, 1)
}
开发者ID:adiferd,项目名称:gauge,代码行数:9,代码来源:specDetails_test.go


示例8: TestInitSpecsCache

func (s *MySuite) TestInitSpecsCache(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "spec1.spec", spec1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{specDir}}
	specInfoGatherer.waitGroup.Add(1)

	specInfoGatherer.initSpecsCache()

	c.Assert(len(specInfoGatherer.specsCache), Equals, 1)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:10,代码来源:specDetails_test.go


示例9: TestGetParsedConcepts

func (s *MySuite) TestGetParsedConcepts(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "concept.cpt", concept1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.projectDir + string(filepath.Separator) + specDir}}

	conceptsMap := specInfoGatherer.getParsedConcepts()

	c.Assert(len(conceptsMap), Equals, 1)
	c.Assert(conceptsMap["foo bar"], NotNil)
	c.Assert(specInfoGatherer.conceptDictionary, NotNil)
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:11,代码来源:specDetails_test.go


示例10: TestGetParsedSpecs

func (s *MySuite) TestGetParsedSpecs(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "spec1.spec", spec1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{specDir}}

	specFiles := util.FindSpecFilesIn(s.specsDir)
	specs := specInfoGatherer.getParsedSpecs(specFiles)

	c.Assert(len(specs), Equals, 1)
	c.Assert(specs[0].Heading.Value, Equals, "Specification Heading")
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:11,代码来源:specDetails_test.go


示例11: TestGetParsedConcepts

func (s *MySuite) TestGetParsedConcepts(c *C) {
	_, err := util.CreateFileIn(s.specsDir, "concept.cpt", concept1)
	c.Assert(err, Equals, nil)
	specInfoGatherer := new(SpecInfoGatherer)

	conceptsMap := specInfoGatherer.getParsedConcepts()

	c.Assert(len(conceptsMap), Equals, 1)
	c.Assert(conceptsMap["foo bar"], NotNil)
	c.Assert(specInfoGatherer.conceptDictionary, NotNil)
}
开发者ID:andrewmkrug,项目名称:gauge,代码行数:11,代码来源:specDetails_test.go


示例12: TestAddingConcepts

func (s *MySuite) TestAddingConcepts(c *C) {
	data := []byte(`# A concept
* first step with "foo"
* second say "hello" to me
* third "foo" step

# second concept
* fourth
* A concept
`)

	data1 := []byte(`# another cpt file
* second say "hello" to me
* fifth step

# concept with <a>
* sixth step with <a>
* seventh param step
`)

	util.CreateFileIn(s.specsDir, "concept.cpt", data)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromConcepts()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 4)

	c.Assert(len(specInfoGatherer.getConceptInfos()), Equals, 2)

	util.CreateFileIn(s.specsDir, "concept1.cpt", data1)

	specInfoGatherer.addConcept(filepath.Join(s.specsDir, "concept1.cpt"))
	allSteps = specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 7)

	c.Assert(len(specInfoGatherer.getConceptInfos()), Equals, 4)

}
开发者ID:Jayasagar,项目名称:gauge,代码行数:41,代码来源:specDetails_test.go


示例13: TestAddingSpecWithParseFailures

func (s *MySuite) TestAddingSpecWithParseFailures(c *C) {
	data := []byte(`NO heading parse failure
* first step with "foo"
* say "hello" to me
* a "final" step
`)

	util.CreateFileIn(s.specsDir, "Spec1.spec", data)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromSpecs()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 0)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 0)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 0)
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:18,代码来源:specDetails_test.go


示例14: TestFindingStepsAndConceptInfosFromConcepts

func (s *MySuite) TestFindingStepsAndConceptInfosFromConcepts(c *C) {
	data := []byte(`# foo bar
* first step with "foo"
* say "hello" to me
* a "final" step
`)

	util.CreateFileIn(s.specsDir, "concept.cpt", data)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromConcepts()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)
	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 0)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 3)

	conceptInfos := specInfoGatherer.getConceptInfos()
	c.Assert(len(conceptInfos), Equals, 1)
	c.Assert(conceptInfos[0].GetFilepath(), Equals, filepath.Join(s.specsDir, "concept.cpt"))
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:22,代码来源:specDetails_test.go


示例15: TestGetAllStepsFromSpecs

func (s *MySuite) TestGetAllStepsFromSpecs(c *C) {
	data := []byte(`Specification Heading
=====================
Scenario 1
----------
* say hello
* say "hello" to me
`)

	specFile, err := util.CreateFileIn(s.specsDir, "Spec1.spec", data)
	c.Assert(err, Equals, nil)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromSpecs()

	c.Assert(len(specInfoGatherer.availableSpecs), Equals, 1)
	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 1)

	steps, ok := specInfoGatherer.fileToStepsMap[specFile]
	c.Assert(ok, Equals, true)
	c.Assert(len(steps), Equals, 2)
	c.Assert(steps[0].lineText, Equals, "say hello")
	c.Assert(steps[1].lineText, Equals, "say \"hello\" to me")
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:24,代码来源:specDetails_test.go


示例16: TestAddingSpecsAndConcepts

func (s *MySuite) TestAddingSpecsAndConcepts(c *C) {
	data := []byte(`# A concept
* first step with "foo"
* second say "hello" to me
* third "foo" step

# second concept
* fourth
* fifth step
* third concept
`)

	data1 := []byte(`# third concept
* second say "hello" to me
* A concept

# fourth concept with <a>
* sixth step with <a>
* seventh "param" step
`)

	data3 := []byte(`Specification Heading
=====================
Scenario 1
----------
* eighth step with "foo"

## scenario 2

* ninth step
`)

	util.CreateFileIn(s.specsDir, "concept.cpt", data)
	util.CreateFileIn(s.specsDir, "concept1.cpt", data1)
	specInfoGatherer := new(specInfoGatherer)

	specInfoGatherer.findAllStepsFromConcepts()
	specInfoGatherer.updateAllStepsList()

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 2)
	allSteps := specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 7)
	stepValues := createStepValueTexts(allSteps)

	c.Assert(stringInSlice("first step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("second say {} to me", stepValues), Equals, true)
	c.Assert(stringInSlice("third {} step", stepValues), Equals, true)
	c.Assert(stringInSlice("fourth", stepValues), Equals, true)
	c.Assert(stringInSlice("fifth step", stepValues), Equals, true)
	c.Assert(stringInSlice("seventh {} step", stepValues), Equals, true)
	c.Assert(stringInSlice("sixth step with {}", stepValues), Equals, true)
	c.Assert(len(specInfoGatherer.getConceptInfos()), Equals, 4)

	_, err := util.CreateFileIn(filepath.Join(s.specsDir, "nested"), "SPEC.spec", data3)
	c.Assert(err, Equals, nil)
	specInfoGatherer.addSpec(filepath.Join(s.specsDir, "nested", "SPEC.spec"))

	c.Assert(len(specInfoGatherer.fileToStepsMap), Equals, 3)
	allSteps = specInfoGatherer.getAvailableSteps()
	c.Assert(len(allSteps), Equals, 9)
	stepValues = createStepValueTexts(allSteps)

	c.Assert(stringInSlice("first step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("second say {} to me", stepValues), Equals, true)
	c.Assert(stringInSlice("third {} step", stepValues), Equals, true)
	c.Assert(stringInSlice("fourth", stepValues), Equals, true)
	c.Assert(stringInSlice("fifth step", stepValues), Equals, true)
	c.Assert(stringInSlice("sixth step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("seventh {} step", stepValues), Equals, true)
	c.Assert(stringInSlice("eighth step with {}", stepValues), Equals, true)
	c.Assert(stringInSlice("ninth step", stepValues), Equals, true)
	c.Assert(len(specInfoGatherer.getConceptInfos()), Equals, 4)
}
开发者ID:Jayasagar,项目名称:gauge,代码行数:73,代码来源:specDetails_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang util.IsSpec函数代码示例发布时间:2022-05-23
下一篇:
Golang runner.TestRunner类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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