Пример #1
0
func makeParameterCopy(parameter *gauge_messages.Parameter) *gauge_messages.Parameter {
	switch parameter.GetParameterType() {
	case gauge_messages.Parameter_Static:
		return &gauge_messages.Parameter{ParameterType: gauge_messages.Parameter_Static.Enum(), Value: proto.String(parameter.GetValue()), Name: proto.String(parameter.GetName())}
	case gauge_messages.Parameter_Dynamic:
		return &gauge_messages.Parameter{ParameterType: gauge_messages.Parameter_Dynamic.Enum(), Value: proto.String(parameter.GetValue()), Name: proto.String(parameter.GetName())}
	case gauge_messages.Parameter_Table:
		return &gauge_messages.Parameter{ParameterType: gauge_messages.Parameter_Table.Enum(), Table: makeTableCopy(parameter.GetTable()), Name: proto.String(parameter.GetName())}
	case gauge_messages.Parameter_Special_String:
		return &gauge_messages.Parameter{ParameterType: gauge_messages.Parameter_Special_String.Enum(), Value: proto.String(parameter.GetValue()), Name: proto.String(parameter.GetName())}
	case gauge_messages.Parameter_Special_Table:
		return &gauge_messages.Parameter{ParameterType: gauge_messages.Parameter_Special_Table.Enum(), Table: makeTableCopy(parameter.GetTable()), Name: proto.String(parameter.GetName())}
	}
	return parameter
}
Пример #2
0
func compareParameter(parameter1 *gauge_messages.Parameter, parameter2 *gauge_messages.Parameter, c *C) {
	if parameter1 != nil && parameter2 != nil {
		c.Assert(parameter1.GetParameterType(), Equals, parameter2.GetParameterType())
		c.Assert(parameter1.GetName(), Equals, parameter2.GetName())
		c.Assert(parameter1.GetValue(), Equals, parameter2.GetValue())
		compareTable(parameter1.GetTable(), parameter2.GetTable(), c)

	} else if (parameter1 == nil && parameter2 != nil) || (parameter1 != nil && parameter2 == nil) {
		c.Log("One parameter was nil and the other wasn't")
		c.Fail()
	}
}
Пример #3
0
func (paramResolver *paramResolver) getResolvedParams(step *step, parent *step, dataTableLookup *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 == static {
			parameter.ParameterType = gauge_messages.Parameter_Static.Enum()
			parameter.Value = proto.String(arg.value)
		} else if arg.argType == dynamic {
			var resolvedArg *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 == specialString {
			parameter.ParameterType = gauge_messages.Parameter_Special_String.Enum()
			parameter.Value = proto.String(arg.value)
		} else if arg.argType == 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

}