本文整理匯總了Golang中github.com/getgauge/gauge/util.CreateFileIn函數的典型用法代碼示例。如果您正苦於以下問題:Golang CreateFileIn函數的具體用法?Golang CreateFileIn怎麽用?Golang CreateFileIn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CreateFileIn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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")
}
示例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)
}
示例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)
}
示例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)
}
示例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"))
}
示例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")
}