本文整理匯總了Golang中github.com/getgauge/gauge/gauge.ArgLookup類的典型用法代碼示例。如果您正苦於以下問題:Golang ArgLookup類的具體用法?Golang ArgLookup怎麽用?Golang ArgLookup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ArgLookup類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PopulateConceptDynamicParams
// Creating a copy of the lookup and populating table values
func PopulateConceptDynamicParams(concept *gauge.Step, dataTableLookup *gauge.ArgLookup) {
//If it is a top level concept
if concept.Parent == nil {
lookup := concept.Lookup.GetCopy()
for key, _ := range lookup.ParamIndexMap {
conceptLookupArg := lookup.GetArg(key)
if conceptLookupArg.ArgType == gauge.Dynamic {
resolvedArg := dataTableLookup.GetArg(conceptLookupArg.Value)
lookup.AddArgValue(key, resolvedArg)
}
}
concept.Lookup = *lookup
}
//Updating values inside the concept step as well
newArgs := make([]*gauge.StepArg, 0)
for _, arg := range concept.Args {
if arg.ArgType == gauge.Dynamic {
if concept.Parent != nil {
newArgs = append(newArgs, concept.Parent.GetArg(arg.Value))
} else {
newArgs = append(newArgs, dataTableLookup.GetArg(arg.Value))
}
} else {
newArgs = append(newArgs, arg)
}
}
concept.Args = newArgs
concept.PopulateFragments()
}
示例2: validateDynamicArg
func validateDynamicArg(argValue string, token *Token, lookup *gauge.ArgLookup) (*gauge.StepArg, *ParseDetailResult) {
if !isConceptHeader(lookup) && !lookup.ContainsArg(argValue) {
return nil, &ParseDetailResult{Error: &ParseError{LineNo: token.LineNo, Message: fmt.Sprintf("Dynamic parameter <%s> could not be resolved", argValue), LineText: token.LineText}}
}
stepArgument := &gauge.StepArg{ArgType: gauge.Dynamic, Value: argValue, Name: argValue}
return stepArgument, nil
}
示例3: GetResolvedParams
func (paramResolver *ParamResolver) GetResolvedParams(step *gauge.Step, parent *gauge.Step, dataTableLookup *gauge.ArgLookup) []*gauge_messages.Parameter {
parameters := make([]*gauge_messages.Parameter, 0)
for _, arg := range step.Args {
parameter := new(gauge_messages.Parameter)
parameter.Name = proto.String(arg.Name)
if arg.ArgType == gauge.Static {
parameter.ParameterType = gauge_messages.Parameter_Static.Enum()
parameter.Value = proto.String(arg.Value)
} else if arg.ArgType == gauge.Dynamic {
var resolvedArg *gauge.StepArg
if parent != nil {
resolvedArg = parent.GetArg(arg.Value)
} else {
resolvedArg = dataTableLookup.GetArg(arg.Value)
}
//In case a special table used in a concept, you will get a dynamic table value which has to be resolved from the concept lookup
parameter.Name = proto.String(resolvedArg.Name)
if resolvedArg.Table.IsInitialized() {
parameter.ParameterType = gauge_messages.Parameter_Special_Table.Enum()
parameter.Table = paramResolver.createProtoStepTable(&resolvedArg.Table, dataTableLookup)
} else {
parameter.ParameterType = gauge_messages.Parameter_Dynamic.Enum()
parameter.Value = proto.String(resolvedArg.Value)
}
} else if arg.ArgType == gauge.SpecialString {
parameter.ParameterType = gauge_messages.Parameter_Special_String.Enum()
parameter.Value = proto.String(arg.Value)
} else if arg.ArgType == gauge.SpecialTable {
parameter.ParameterType = gauge_messages.Parameter_Special_Table.Enum()
parameter.Table = paramResolver.createProtoStepTable(&arg.Table, dataTableLookup)
} else {
parameter.ParameterType = gauge_messages.Parameter_Table.Enum()
parameter.Table = paramResolver.createProtoStepTable(&arg.Table, dataTableLookup)
}
parameters = append(parameters, parameter)
}
return parameters
}
示例4: addInlineTableRow
func addInlineTableRow(step *gauge.Step, token *Token, argLookup *gauge.ArgLookup) ParseResult {
dynamicArgMatcher := regexp.MustCompile("^<(.*)>$")
tableValues := make([]gauge.TableCell, 0)
warnings := make([]*Warning, 0)
for _, tableValue := range token.Args {
if dynamicArgMatcher.MatchString(tableValue) {
match := dynamicArgMatcher.FindAllStringSubmatch(tableValue, -1)
param := match[0][1]
if !argLookup.ContainsArg(param) {
tableValues = append(tableValues, gauge.TableCell{Value: tableValue, CellType: gauge.Static})
warnings = append(warnings, &Warning{LineNo: token.LineNo, Message: fmt.Sprintf("Dynamic param <%s> could not be resolved, Treating it as static param", param)})
} else {
tableValues = append(tableValues, gauge.TableCell{Value: param, CellType: gauge.Dynamic})
}
} else {
tableValues = append(tableValues, gauge.TableCell{Value: tableValue, CellType: gauge.Static})
}
}
step.AddInlineTableRow(tableValues)
return ParseResult{Ok: true, Warnings: warnings}
}
示例5: createProtoStepTable
func (resolver *ParamResolver) createProtoStepTable(table *gauge.Table, dataTableLookup *gauge.ArgLookup) *gauge_messages.ProtoTable {
protoTable := new(gauge_messages.ProtoTable)
protoTable.Headers = &gauge_messages.ProtoTableRow{Cells: table.Headers}
tableRows := make([]*gauge_messages.ProtoTableRow, 0)
if len(table.Columns) == 0 {
protoTable.Rows = tableRows
return protoTable
}
for i := 0; i < len(table.Columns[0]); i++ {
row := make([]string, 0)
for _, header := range table.Headers {
tableCell := table.Get(header)[i]
value := tableCell.Value
if tableCell.CellType == gauge.Dynamic {
//if concept has a table with dynamic cell, fetch from datatable
value = dataTableLookup.GetArg(tableCell.Value).Value
}
row = append(row, value)
}
tableRows = append(tableRows, &gauge_messages.ProtoTableRow{Cells: row})
}
protoTable.Rows = tableRows
return protoTable
}