Пример #1
0
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
}