How to use initStepsCache method of infoGatherer Package

Best Gauge code snippet using infoGatherer.initStepsCache

specDetails_test.go

Source:specDetails_test.go Github

copy

Full Screen

...183 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}184 specInfoGatherer.waitGroup.Add(3)185 specInfoGatherer.initConceptsCache()186 specInfoGatherer.initSpecsCache()187 specInfoGatherer.initStepsCache()188 c.Assert(len(specInfoGatherer.stepsCache.steps[f]), Equals, 2)189 c.Assert(len(specInfoGatherer.stepsCache.steps[f1]), Equals, 3)190}191func (s *MySuite) TestInitTagsCache(c *C) {192 f, _ := createFileIn(s.specsDir, "specWithTags.spec", specWithTags)193 f, _ = filepath.Abs(f)194 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}195 specInfoGatherer.waitGroup.Add(2)196 specInfoGatherer.initSpecsCache()197 specInfoGatherer.initTagsCache()198 c.Assert(len(specInfoGatherer.Tags()), Equals, 5)199}200func (s *MySuite) TestInitTagsCacheWithMultipleFiles(c *C) {201 f, _ := createFileIn(s.specsDir, "specWithTags.spec", specWithTags)202 f, _ = filepath.Abs(f)203 f1, _ := createFileIn(s.specsDir, "spec2WithTags.spec", spec2WithTags)204 f1, _ = filepath.Abs(f1)205 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}206 specInfoGatherer.waitGroup.Add(2)207 specInfoGatherer.initSpecsCache()208 specInfoGatherer.initTagsCache()209 c.Assert(len(specInfoGatherer.Tags()), Equals, 6)210}211func (s *MySuite) TestGetStepsFromCachedSpecs(c *C) {212 var stepsFromSpecsMap = make(map[string][]*gauge.Step, 0)213 f, _ := createFileIn(s.specsDir, "spec1.spec", spec1)214 f, _ = filepath.Abs(f)215 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}216 specInfoGatherer.waitGroup.Add(3)217 specInfoGatherer.initSpecsCache()218 stepsFromSpecsMap = specInfoGatherer.getStepsFromCachedSpecs()219 c.Assert(len(stepsFromSpecsMap[f]), Equals, 2)220 c.Assert(stepsFromSpecsMap[f][0].Value, Equals, "say hello")221 c.Assert(stepsFromSpecsMap[f][1].Value, Equals, "say {} to me")222}223func (s *MySuite) TestGetStepsFromCachedConcepts(c *C) {224 var stepsFromConceptsMap = make(map[string][]*gauge.Step, 0)225 f, _ := createFileIn(s.specsDir, "concept1.cpt", concept1)226 f, _ = filepath.Abs(f)227 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}228 specInfoGatherer.waitGroup.Add(3)229 specInfoGatherer.initSpecsCache()230 specInfoGatherer.initConceptsCache()231 stepsFromConceptsMap = specInfoGatherer.getStepsFromCachedConcepts()232 c.Assert(len(stepsFromConceptsMap[f]), Equals, 3)233 c.Assert(stepsFromConceptsMap[f][0].Value, Equals, "first step with {}")234 c.Assert(stepsFromConceptsMap[f][1].Value, Equals, "say {} to me")235 c.Assert(stepsFromConceptsMap[f][2].Value, Equals, "a {} step")236}237func (s *MySuite) TestGetAvailableSteps(c *C) {238 var steps []*gauge.Step239 createFileIn(s.specsDir, "spec1.spec", spec1)240 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}241 specInfoGatherer.waitGroup.Add(2)242 specInfoGatherer.initSpecsCache()243 specInfoGatherer.initStepsCache()244 steps = specInfoGatherer.Steps(true)245 c.Assert(len(steps), Equals, 2)246 if !hasStep(steps, "say hello") {247 c.Fatalf("Step value not found %s", "say hello")248 }249 if !hasStep(steps, "say {} to me") {250 c.Fatalf("Step value not found %s", "say {} to me")251 }252}253func (s *MySuite) TestGetAvailableStepsShouldFilterDuplicates(c *C) {254 var steps []*gauge.Step255 createFileIn(s.specsDir, "spec2.spec", spec2)256 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}257 specInfoGatherer.waitGroup.Add(2)258 specInfoGatherer.initSpecsCache()259 specInfoGatherer.initStepsCache()260 steps = specInfoGatherer.Steps(true)261 c.Assert(len(steps), Equals, 2)262 if !hasStep(steps, "say hello") {263 c.Fatalf("Step value not found %s", "say hello")264 }265 if !hasStep(steps, "say {} to me") {266 c.Fatalf("Step value not found %s", "say {} to me")267 }268}269func (s *MySuite) TestGetAvailableStepsShouldFilterConcepts(c *C) {270 var steps []*gauge.Step271 createFileIn(s.specsDir, "concept1.cpt", concept4)272 createFileIn(s.specsDir, "spec1.spec", specWithConcept)273 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}274 specInfoGatherer.waitGroup.Add(3)275 specInfoGatherer.initConceptsCache()276 specInfoGatherer.initSpecsCache()277 specInfoGatherer.initStepsCache()278 steps = specInfoGatherer.Steps(true)279 c.Assert(len(steps), Equals, 1)280 if hasStep(steps, "foo bar with 1 step") {281 c.Fatalf("Step value found %s", "foo bar with 1 step")282 }283 steps = specInfoGatherer.Steps(false)284 c.Assert(len(steps), Equals, 2)285 if !hasStep(steps, "foo bar with 1 step") {286 c.Fatalf("Step value not found %s", "foo bar with 1 step")287 }288}289func (s *MySuite) TestGetAvailableAllStepsShouldFilterConcepts(c *C) {290 var steps []*gauge.Step291 createFileIn(s.specsDir, "concept1.cpt", concept4)292 createFileIn(s.specsDir, "spec1.spec", specWithConcept)293 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}294 specInfoGatherer.waitGroup.Add(3)295 specInfoGatherer.initConceptsCache()296 specInfoGatherer.initSpecsCache()297 specInfoGatherer.initStepsCache()298 steps = specInfoGatherer.AllSteps(true)299 c.Assert(len(steps), Equals, 2)300 if hasStep(steps, "foo bar with 1 step") {301 c.Fatalf("Step value found %s", "foo bar with 1 step")302 }303 steps = specInfoGatherer.AllSteps(false)304 c.Assert(len(steps), Equals, 3)305 if !hasStep(steps, "foo bar with 1 step") {306 c.Fatalf("Step value not found %s", "foo bar with 1 step")307 }308}309func hasStep(steps []*gauge.Step, stepText string) bool {310 for _, step := range steps {311 if step.Value == stepText {312 return true313 }314 }315 return false316}317func (s *MySuite) TestHasSpecForSpecDetail(c *C) {318 c.Assert((&SpecDetail{}).HasSpec(), Equals, false)319 c.Assert((&SpecDetail{Spec: &gauge.Specification{}}).HasSpec(), Equals, false)320 c.Assert((&SpecDetail{Spec: &gauge.Specification{Heading: &gauge.Heading{}}}).HasSpec(), Equals, true)321}322func (s *MySuite) TestGetAvailableSpecDetails(c *C) {323 _, err := createFileIn(s.specsDir, "spec1.spec", spec1)324 c.Assert(err, Equals, nil)325 sig := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}, specsCache: specsCache{specDetails: make(map[string]*SpecDetail)}}326 specFiles := util.FindSpecFilesIn(s.specsDir)327 sig.specsCache.specDetails[specFiles[0]] = &SpecDetail{Spec: &gauge.Specification{Heading: &gauge.Heading{Value: "Specification Heading"}}}328 details := sig.GetAvailableSpecDetails(specFiles)329 c.Assert(len(details), Equals, 1)330 c.Assert(details[0].Spec.Heading.Value, Equals, "Specification Heading")331}332func (s *MySuite) TestGetAvailableSpecDetailsInDefaultDir(c *C) {333 _, err := createFileIn(s.specsDir, "spec1.spec", spec1)334 c.Assert(err, Equals, nil)335 wd, _ := os.Getwd()336 os.Chdir(s.projectDir)337 defer os.Chdir(wd)338 sig := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}, specsCache: specsCache{specDetails: make(map[string]*SpecDetail)}}339 specFiles := util.FindSpecFilesIn(specDir)340 sig.specsCache.specDetails[specFiles[0]] = &SpecDetail{Spec: &gauge.Specification{Heading: &gauge.Heading{Value: "Specification Heading"}}}341 details := sig.GetAvailableSpecDetails([]string{})342 c.Assert(len(details), Equals, 1)343 c.Assert(details[0].Spec.Heading.Value, Equals, "Specification Heading")344}345func (s *MySuite) TestGetAvailableSpecDetailsWithEmptyCache(c *C) {346 _, err := createFileIn(s.specsDir, "spec1.spec", spec1)347 c.Assert(err, Equals, nil)348 sig := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}349 details := sig.GetAvailableSpecDetails([]string{})350 c.Assert(len(details), Equals, 0)351}352func (s *MySuite) TestParamsForStepFile(c *C) {353 file, _ := createFileIn(s.specsDir, "spec3.spec", spec3)354 file, _ = filepath.Abs(file)355 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}356 specInfoGatherer.waitGroup.Add(2)357 specInfoGatherer.initConceptsCache()358 specInfoGatherer.initSpecsCache()359 specInfoGatherer.initStepsCache()360 specInfoGatherer.initParamsCache()361 staticParams := specInfoGatherer.Params(file, gauge.Static)362 c.Assert(len(staticParams), Equals, 1)363 dynamicParams := specInfoGatherer.Params(file, gauge.Dynamic)364 c.Assert(len(dynamicParams), Equals, 3)365 hasParam := func(param string, list []gauge.StepArg) bool {366 for _, p := range list {367 if p.ArgValue() == param {368 return true369 }370 }371 return false372 }373 if !hasParam("hello", staticParams) {374 c.Errorf(`Param "hello" not found`)375 }376 if !hasParam("bye", dynamicParams) {377 c.Errorf(`Param "bye" not found`)378 }379 if !hasParam("Col1", dynamicParams) {380 c.Errorf(`Param "Col1" not found`)381 }382 if !hasParam("Col2", dynamicParams) {383 c.Errorf(`Param "Col1" not found`)384 }385}386func (s *MySuite) TestParamsForConceptFile(c *C) {387 file, _ := createFileIn(s.specsDir, "concept3.cpt", concept3)388 file, _ = filepath.Abs(file)389 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}390 specInfoGatherer.waitGroup.Add(2)391 specInfoGatherer.initConceptsCache()392 specInfoGatherer.initSpecsCache()393 specInfoGatherer.initStepsCache()394 specInfoGatherer.initParamsCache()395 staticParams := specInfoGatherer.Params(file, gauge.Static)396 c.Assert(len(staticParams), Equals, 1)397 dynamicParams := specInfoGatherer.Params(file, gauge.Dynamic)398 c.Assert(len(dynamicParams), Equals, 2)399 hasParam := func(param string, list []gauge.StepArg) bool {400 for _, p := range list {401 if p.ArgValue() == param {402 return true403 }404 }405 return false406 }407 if !hasParam("foo", staticParams) {408 c.Errorf(`Param "foo" not found`)409 }410 if !hasParam("param", dynamicParams) {411 c.Errorf(`Param "param" not found`)412 }413 if !hasParam("final", dynamicParams) {414 c.Errorf(`Param "final" not found`)415 }416}417func (s *MySuite) TestAllStepsOnFileRename(c *C) {418 file, _ := createFileIn(s.specsDir, "spec1.spec", spec1)419 file, _ = filepath.Abs(file)420 specInfoGatherer := &SpecInfoGatherer{SpecDirs: []string{s.specsDir}}421 specInfoGatherer.initSpecsCache()422 specInfoGatherer.initStepsCache()423 c.Assert(len(specInfoGatherer.AllSteps(true)), Equals, 2)424 renameFileIn(s.specsDir, "spec1.spec", "spec42.spec")425 c.Assert(len(specInfoGatherer.AllSteps(true)), Equals, 2)426}427func createFileIn(dir string, fileName string, data []byte) (string, error) {428 os.MkdirAll(dir, 0755)429 err := ioutil.WriteFile(filepath.Join(dir, fileName), data, 0644)430 return filepath.Join(dir, fileName), err431}432func renameFileIn(dir string, oldFileName string, newFileName string) (string, error) {433 err := os.Rename(filepath.Join(dir, oldFileName), filepath.Join(dir, newFileName))434 return filepath.Join(dir, newFileName), err435}436func createDirIn(dir string, dirName string) (string, error) {...

Full Screen

Full Screen

specDetails.go

Source:specDetails.go Github

copy

Full Screen

...49 // Concepts parsed first because we need to create a concept dictionary that spec parsing can use50 s.waitGroup.Add(3)51 s.initConceptsCache()52 s.initSpecsCache()53 s.initStepsCache()54}55func (s *SpecInfoGatherer) initSpecsCache() {56 defer s.waitGroup.Done()57 s.specsCache = make(map[string]*SpecDetail, 0)58 details := s.getParsedSpecs(getSpecFiles(s.SpecDirs))59 logger.APILog.Info("Initializing specs cache with %d specs", len(details))60 for _, d := range details {61 logger.APILog.Debug("Adding specs from %s", d.Spec.FileName)62 s.addToSpecsCache(d.Spec.FileName, d)63 }64}65func getSpecFiles(specs []string) []string {66 var specFiles []string67 for _, dir := range specs {68 specFiles = append(specFiles, util.FindSpecFilesIn(dir)...)69 }70 return specFiles71}72func (s *SpecInfoGatherer) initConceptsCache() {73 defer s.waitGroup.Done()74 s.conceptsCache = make(map[string][]*gauge.Concept, 0)75 parsedConcepts := s.getParsedConcepts()76 logger.APILog.Info("Initializing concepts cache with %d concepts", len(parsedConcepts))77 for _, concept := range parsedConcepts {78 logger.APILog.Debug("Adding concepts from %s", concept.FileName)79 s.addToConceptsCache(concept.FileName, concept)80 }81}82func (s *SpecInfoGatherer) initStepsCache() {83 defer s.waitGroup.Done()84 s.stepsCache = make(map[string]*gauge.StepValue, 0)85 stepsFromSpecs := s.getStepsFromCachedSpecs()86 stepsFromConcepts := s.getStepsFromCachedConcepts()87 allSteps := append(stepsFromSpecs, stepsFromConcepts...)88 logger.APILog.Info("Initializing steps cache with %d steps", len(allSteps))89 s.addToStepsCache(allSteps)90}91func (s *SpecInfoGatherer) addToSpecsCache(key string, value *SpecDetail) {92 s.mutex.Lock()93 s.specsCache[key] = value94 s.mutex.Unlock()95}96func (s *SpecInfoGatherer) addToConceptsCache(key string, value *gauge.Concept) {...

Full Screen

Full Screen

initStepsCache

Using AI Code Generation

copy

Full Screen

1initStepsCache();2initStepsCache();3initStepsCache();4initStepsCache();5initStepsCache();6initStepsCache();7initStepsCache();8initStepsCache();9initStepsCache();10initStepsCache();11initStepsCache();12initStepsCache();13initStepsCache();14initStepsCache();15initStepsCache();16initStepsCache();17initStepsCache();18initStepsCache();19initStepsCache();20initStepsCache();

Full Screen

Full Screen

initStepsCache

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 ig := gatherers.NewInfoGatherer()4 dr := diskrecorder.NewDiskRecorder()5 r := recorder.NewRecorder(dr)6 ig.initStepsCache(r)7}8import (9func main() {10 ig := gatherers.NewInfoGatherer()11 dr := diskrecorder.NewDiskRecorder()12 r := recorder.NewRecorder(dr)13 ig.Gather(r)14}15import (16func main() {17 ig := gatherers.NewInfoGatherer()18 dr := diskrecorder.NewDiskRecorder()19 r := recorder.NewRecorder(dr)20 ig.GatherAll(r)21}22import (

Full Screen

Full Screen

initStepsCache

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 buildNumber, err := strconv.Atoi(os.Args[2])4 if err != nil {5 log.Fatalf("error in converting build number to int: %v", err)6 }7 gcsClient := gcs.NewClient()8 ctx := context.Background()9 bucket, object, err := gcs.PathToBucketObject(gcsPath)10 if err != nil {11 log.Fatalf("error in getting bucket and object from GCS path: %v", err)12 }13 reader := gcsClient.Bucket(bucket).Object(object).NewReader(ctx)14 contents, err := ioutil.ReadAll(reader)15 if err != nil {16 log.Fatalf("error in reading file contents: %v", err)17 }18 testGroupName := path.Base(path.Dir(gcsPath))19 tabName := path.Base(gcsPath)20 dashboardName := path.Base(path.Dir(path.Dir(gcsPath)))21 infoGatherer := metadata.NewInfoGatherer(testGroupName, dashboardName, tabName)22 infoGatherer.InitStepsCache(contents)23 startTime, err := infoGatherer.GetStepStartTime(stepName, buildNumber)24 if err != nil {25 log.Fatalf("error in getting step start time: %v", err)26 }27 fmt.Println(startTime)28}29import (

Full Screen

Full Screen

initStepsCache

Using AI Code Generation

copy

Full Screen

1import (2func main() {3}4import (5func main() {6}7import (8func main() {9}10type MyStruct struct {11}12func NewMyStruct() *MyStruct {13 return &MyStruct{}14}15func NewMyStruct() *MyStruct {16 return &MyStruct{17 myMap: make(map[string]string),18 }19}20cannot use make(map[string]string) (type map[string]string) as type map[string]string in field value21type MyStruct struct {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gauge automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful