mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 18:12:43 -05:00
Update query JSON output to be consistent across pipelings - also handle duplicate column names. Closes #4317
This commit is contained in:
@@ -134,7 +134,10 @@ func (c *DbClient) ExecuteInSession(ctx context.Context, session *db_common.Data
|
||||
return
|
||||
}
|
||||
|
||||
colDefs := fieldDescriptionsToColumns(rows.FieldDescriptions(), session.Connection.Conn())
|
||||
colDefs, err := fieldDescriptionsToColumns(rows.FieldDescriptions(), session.Connection.Conn())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := queryresult.NewResult(colDefs)
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package db_client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
"github.com/turbot/steampipe/pkg/query/queryresult"
|
||||
)
|
||||
|
||||
@@ -18,7 +20,7 @@ func columnTypeDatabaseTypeName(field pgconn.FieldDescription, connection *pgx.C
|
||||
return strconv.FormatInt(int64(field.DataTypeOID), 10)
|
||||
}
|
||||
|
||||
func fieldDescriptionsToColumns(fieldDescriptions []pgconn.FieldDescription, connection *pgx.Conn) []*queryresult.ColumnDef {
|
||||
func fieldDescriptionsToColumns(fieldDescriptions []pgconn.FieldDescription, connection *pgx.Conn) ([]*queryresult.ColumnDef, error) {
|
||||
cols := make([]*queryresult.ColumnDef, len(fieldDescriptions))
|
||||
|
||||
for i, f := range fieldDescriptions {
|
||||
@@ -29,5 +31,30 @@ func fieldDescriptionsToColumns(fieldDescriptions []pgconn.FieldDescription, con
|
||||
DataType: typeName,
|
||||
}
|
||||
}
|
||||
return cols
|
||||
|
||||
// Ensure column names are unique
|
||||
if err := ensureUniqueColumnName(cols); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cols, nil
|
||||
}
|
||||
|
||||
func ensureUniqueColumnName(cols []*queryresult.ColumnDef) error {
|
||||
// create a unique name generator
|
||||
nameGenerator := utils.NewUniqueNameGenerator()
|
||||
|
||||
for colIdx, col := range cols {
|
||||
uniqueName, err := nameGenerator.GetUniqueName(col.Name, colIdx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error generating unique column name: %w", err)
|
||||
}
|
||||
// if the column name has changed, store the original name and update the column name to be the unique name
|
||||
if uniqueName != col.Name {
|
||||
// set the original name first, BEFORE mutating name
|
||||
col.OriginalName = col.Name
|
||||
col.Name = uniqueName
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -10,11 +10,16 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/query/queryresult"
|
||||
)
|
||||
|
||||
// ColumnNames :: extract names from columns
|
||||
func ColumnNames(columns []*queryresult.ColumnDef) []string {
|
||||
// columnNames builds a list of name from a slice of column defs - respecting the original name if present
|
||||
func columnNames(columns []*queryresult.ColumnDef) []string {
|
||||
var colNames = make([]string, len(columns))
|
||||
for i, c := range columns {
|
||||
colNames[i] = c.Name
|
||||
// respect original name
|
||||
if c.OriginalName != "" {
|
||||
colNames[i] = c.OriginalName
|
||||
} else {
|
||||
colNames[i] = c.Name
|
||||
}
|
||||
}
|
||||
|
||||
return colNames
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/karrick/gows"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
pqueryresult "github.com/turbot/pipe-fittings/queryresult"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
@@ -184,6 +185,7 @@ func getTerminalColumnsRequiredForString(str string) int {
|
||||
}
|
||||
|
||||
type jsonOutput struct {
|
||||
Columns []pqueryresult.ColumnDef `json:"columns"`
|
||||
Rows []map[string]interface{} `json:"rows"`
|
||||
Metadata *queryresult.TimingResult `json:"metadata,omitempty"`
|
||||
}
|
||||
@@ -199,12 +201,27 @@ func displayJSON(ctx context.Context, result *queryresult.Result) (int, *queryre
|
||||
rowErrors := 0
|
||||
jsonOutput := newJSONOutput()
|
||||
|
||||
// add column defs to the JSON output
|
||||
for _, col := range result.Cols {
|
||||
// create a new column def, converting the data type to lowercase
|
||||
c := pqueryresult.ColumnDef{
|
||||
Name: col.Name,
|
||||
OriginalName: col.OriginalName,
|
||||
DataType: strings.ToLower(col.DataType),
|
||||
}
|
||||
// add to the column def array
|
||||
jsonOutput.Columns = append(jsonOutput.Columns, c)
|
||||
}
|
||||
|
||||
// define function to add each row to the JSON output
|
||||
rowFunc := func(row []interface{}, result *queryresult.Result) {
|
||||
record := map[string]interface{}{}
|
||||
for idx, col := range result.Cols {
|
||||
value, _ := ParseJSONOutputColumnValue(row[idx], col)
|
||||
record[col.Name] = value
|
||||
// get the column def
|
||||
c := jsonOutput.Columns[idx]
|
||||
// add the value under the unique column name
|
||||
record[c.Name] = value
|
||||
}
|
||||
jsonOutput.Rows = append(jsonOutput.Rows, record)
|
||||
}
|
||||
@@ -237,7 +254,7 @@ func displayCSV(ctx context.Context, result *queryresult.Result) (int, *queryres
|
||||
csvWriter.Comma = []rune(cmdconfig.Viper().GetString(constants.ArgSeparator))[0]
|
||||
|
||||
if cmdconfig.Viper().GetBool(constants.ArgHeader) {
|
||||
_ = csvWriter.Write(ColumnNames(result.Cols))
|
||||
_ = csvWriter.Write(columnNames(result.Cols))
|
||||
}
|
||||
|
||||
// print the data as it comes
|
||||
@@ -291,16 +308,19 @@ func displayLine(ctx context.Context, result *queryresult.Result) (int, *queryre
|
||||
lineFormat := fmt.Sprintf("%%-%ds | %%s\n", maxColNameLength)
|
||||
multiLineFormat := fmt.Sprintf("%%-%ds | %%-%ds", maxColNameLength, requiredTerminalColumnsForValuesOfRecord)
|
||||
|
||||
fmt.Printf("-[ RECORD %-2d ]%s\n", (itemIdx + 1), strings.Repeat("-", 75))
|
||||
fmt.Printf("-[ RECORD %-2d ]%s\n", itemIdx+1, strings.Repeat("-", 75)) //nolint:forbidigo // intentional use of fmt
|
||||
|
||||
// get the column names (this takes into account the original name)
|
||||
columnNames := columnNames(result.Cols)
|
||||
for idx, column := range recordAsString {
|
||||
lines := strings.Split(column, "\n")
|
||||
if len(lines) == 1 {
|
||||
fmt.Printf(lineFormat, result.Cols[idx].Name, lines[0])
|
||||
fmt.Printf(lineFormat, columnNames[idx], lines[0])
|
||||
} else {
|
||||
for lineIdx, line := range lines {
|
||||
if lineIdx == 0 {
|
||||
// the first line
|
||||
fmt.Printf(multiLineFormat, result.Cols[idx].Name, line)
|
||||
fmt.Printf(multiLineFormat, columnNames[idx], line)
|
||||
} else {
|
||||
// next lines
|
||||
fmt.Printf(multiLineFormat, "", line)
|
||||
@@ -347,10 +367,12 @@ func displayTable(ctx context.Context, result *queryresult.Result) (int, *queryr
|
||||
var colConfigs []table.ColumnConfig
|
||||
headers := make(table.Row, len(result.Cols))
|
||||
|
||||
for idx, column := range result.Cols {
|
||||
headers[idx] = column.Name
|
||||
// get the column names (this takes into account the original name)
|
||||
columnNames := columnNames(result.Cols)
|
||||
for idx, columnName := range columnNames {
|
||||
headers[idx] = columnName
|
||||
colConfigs = append(colConfigs, table.ColumnConfig{
|
||||
Name: column.Name,
|
||||
Name: columnName,
|
||||
Number: idx + 1,
|
||||
WidthMax: constants.MaxColumnWidth,
|
||||
})
|
||||
|
||||
@@ -4,9 +4,10 @@ import "reflect"
|
||||
|
||||
// ColumnDef is a struct used to store column information from query results
|
||||
type ColumnDef struct {
|
||||
Name string `json:"name"`
|
||||
DataType string `json:"data_type"`
|
||||
isScalar *bool
|
||||
Name string `json:"name"`
|
||||
DataType string `json:"data_type"`
|
||||
isScalar *bool
|
||||
OriginalName string `json:"original_name"`
|
||||
}
|
||||
|
||||
// IsScalar checks if the given value is a scalar value
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "resource_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "mod_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "start_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "end_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "auto_generated",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "source_definition",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "is_anonymous",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "severity",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "width",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "sql",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "args",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "query",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "qualified_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "documentation",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "tags",
|
||||
"data_type": "jsonb"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"args": {
|
||||
"args_list": null,
|
||||
"refs": null
|
||||
},
|
||||
"auto_generated": false,
|
||||
"description": "Sample control to test introspection functionality",
|
||||
"documentation": null,
|
||||
"end_line_number": 33,
|
||||
"file_name": "/Users/pskrbasu/work/src/steampipe/tests/acceptance/test_data/mods/introspection_table_mod/resources.sp",
|
||||
"is_anonymous": false,
|
||||
"mod_name": "introspection_table_mod",
|
||||
"params": null,
|
||||
"path": [
|
||||
[
|
||||
"mod.introspection_table_mod",
|
||||
"introspection_table_mod.benchmark.sample_benchmark_1",
|
||||
"introspection_table_mod.control.sample_control_1"
|
||||
]
|
||||
],
|
||||
"qualified_name": "introspection_table_mod.control.sample_control_1",
|
||||
"query": "introspection_table_mod.query.sample_query_1",
|
||||
"resource_name": "sample_control_1",
|
||||
"severity": "high",
|
||||
"source_definition": "control \"sample_control_1\" {\n title = \"Sample control 1\"\n description = \"Sample control to test introspection functionality\"\n query = query.sample_query_1\n severity = \"high\"\n tags = {\n \"foo\": \"bar\"\n }\n}",
|
||||
"sql": null,
|
||||
"start_line_number": 25,
|
||||
"tags": {
|
||||
"foo": "bar"
|
||||
},
|
||||
"title": "Sample control 1",
|
||||
"type": null,
|
||||
"width": null
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,50 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "column_0",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_1",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_2",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_3",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_4",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_5",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_6",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_7",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_8",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_9",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"column_0": "column_0-0",
|
||||
@@ -130,38 +176,6 @@
|
||||
"column_9": "column_9-1005",
|
||||
"id": 1005
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 201108250,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_high_row_count",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 5000,
|
||||
"hydrate_calls": 0,
|
||||
"start_time": "2024-04-11T11:17:24+05:30",
|
||||
"duration": 155,
|
||||
"columns": [
|
||||
"column_0",
|
||||
"column_1",
|
||||
"column_2",
|
||||
"column_3",
|
||||
"column_4",
|
||||
"column_5",
|
||||
"column_6",
|
||||
"column_7",
|
||||
"column_8",
|
||||
"column_9",
|
||||
"id"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": null
|
||||
}
|
||||
],
|
||||
"rows_returned": 10,
|
||||
"rows_fetched": 5000,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,90 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "column_1",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_10",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_11",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_12",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_13",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_14",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_15",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_16",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_17",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_18",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_19",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_2",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_20",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_3",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_4",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_5",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_6",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_7",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_8",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_9",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"column_1": "parallelHydrate1",
|
||||
@@ -23,54 +109,6 @@
|
||||
"column_9": "parallelHydrate9",
|
||||
"id": 0
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 1076604791,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_parallel_hydrate_columns",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 500,
|
||||
"hydrate_calls": 10000,
|
||||
"start_time": "2024-04-11T11:43:26+05:30",
|
||||
"duration": 1039,
|
||||
"columns": [
|
||||
"column_1",
|
||||
"column_10",
|
||||
"column_11",
|
||||
"column_12",
|
||||
"column_13",
|
||||
"column_14",
|
||||
"column_15",
|
||||
"column_16",
|
||||
"column_17",
|
||||
"column_18",
|
||||
"column_19",
|
||||
"column_2",
|
||||
"column_20",
|
||||
"column_3",
|
||||
"column_4",
|
||||
"column_5",
|
||||
"column_6",
|
||||
"column_7",
|
||||
"column_8",
|
||||
"column_9",
|
||||
"id"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 500,
|
||||
"hydrate_calls": 10000
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "float32_data",
|
||||
"data_type": "float8"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "int64_data",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "uint16_data",
|
||||
"data_type": "int8"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"float32_data": 4.4285712242126465,
|
||||
@@ -6,37 +24,6 @@
|
||||
"int64_data": 465,
|
||||
"uint16_data": 341
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 39542459,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_all_numeric_column",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 10,
|
||||
"hydrate_calls": 30,
|
||||
"start_time": "2024-04-11T11:44:55+05:30",
|
||||
"duration": 2,
|
||||
"columns": [
|
||||
"float32_data",
|
||||
"id",
|
||||
"int64_data",
|
||||
"uint16_data"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 31
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 10,
|
||||
"hydrate_calls": 30
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,37 +1,14 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "from_qual_column",
|
||||
"data_type": "text"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"from_qual_column": "2"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 40179750,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_transforms",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 1,
|
||||
"hydrate_calls": 0,
|
||||
"start_time": "2024-04-11T11:49:42+05:30",
|
||||
"duration": 3,
|
||||
"columns": [
|
||||
"from_qual_column",
|
||||
"id"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 1,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "transform_method_column",
|
||||
"data_type": "text"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"transform_method_column": "Transform method"
|
||||
@@ -6,29 +12,6 @@
|
||||
{
|
||||
"transform_method_column": "Transform method"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 40391583,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_transforms",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 2,
|
||||
"hydrate_calls": 0,
|
||||
"start_time": "2024-04-11T11:45:30+05:30",
|
||||
"duration": 3,
|
||||
"columns": [
|
||||
"transform_method_column",
|
||||
"id"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": null
|
||||
}
|
||||
],
|
||||
"rows_returned": 2,
|
||||
"rows_fetched": 2,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "a",
|
||||
"data_type": "int4"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"a": 1
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 141791,
|
||||
"scans": [],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "string_column",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "json_column",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "boolean_column",
|
||||
"data_type": "bool"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"boolean_column": true,
|
||||
@@ -13,37 +31,6 @@
|
||||
},
|
||||
"string_column": "stringValuesomething-0"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 52987458,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_all_column_types",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 100,
|
||||
"hydrate_calls": 200,
|
||||
"start_time": "2024-04-11T11:39:03+05:30",
|
||||
"duration": 14,
|
||||
"columns": [
|
||||
"id",
|
||||
"string_column",
|
||||
"json_column",
|
||||
"boolean_column"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 100,
|
||||
"hydrate_calls": 200
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,11 +1,62 @@
|
||||
{
|
||||
"rows": [],
|
||||
"metadata": {
|
||||
"Duration": 42311542,
|
||||
"scans": [],
|
||||
"rows_returned": 0,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "column_0",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_1",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_2",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_3",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_4",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_5",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_6",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_7",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_8",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "column_9",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "sp_connection_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "sp_ctx",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "_ctx",
|
||||
"data_type": "jsonb"
|
||||
}
|
||||
],
|
||||
"rows": []
|
||||
}
|
||||
|
||||
@@ -1,4 +1,30 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "hydrate_column_1",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "hydrate_column_2",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "hydrate_column_3",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "hydrate_column_4",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "hydrate_column_5",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"hydrate_column_1": "hydrate1-0",
|
||||
@@ -8,39 +34,6 @@
|
||||
"hydrate_column_5": "hydrate5-0-hydrate4-0-hydrate1-0",
|
||||
"id": 0
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 2085913625,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_hydrate_columns_dependency",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 2,
|
||||
"hydrate_calls": 10,
|
||||
"start_time": "2024-04-11T12:34:06+05:30",
|
||||
"duration": 2045,
|
||||
"columns": [
|
||||
"hydrate_column_1",
|
||||
"hydrate_column_2",
|
||||
"hydrate_column_3",
|
||||
"hydrate_column_4",
|
||||
"hydrate_column_5",
|
||||
"id"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 2,
|
||||
"hydrate_calls": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,114 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "nullcolumn",
|
||||
"data_type": "bpchar"
|
||||
},
|
||||
{
|
||||
"name": "booleancolumn",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "textcolumn1",
|
||||
"data_type": "bpchar"
|
||||
},
|
||||
{
|
||||
"name": "textcolumn2",
|
||||
"data_type": "varchar"
|
||||
},
|
||||
{
|
||||
"name": "textcolumn3",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "integercolumn1",
|
||||
"data_type": "int2"
|
||||
},
|
||||
{
|
||||
"name": "integercolumn2",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "integercolumn3",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "integercolumn4",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "integercolumn5",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "numericcolumn",
|
||||
"data_type": "numeric"
|
||||
},
|
||||
{
|
||||
"name": "realcolumn",
|
||||
"data_type": "float4"
|
||||
},
|
||||
{
|
||||
"name": "floatcolumn",
|
||||
"data_type": "float8"
|
||||
},
|
||||
{
|
||||
"name": "date1",
|
||||
"data_type": "date"
|
||||
},
|
||||
{
|
||||
"name": "time1",
|
||||
"data_type": "time"
|
||||
},
|
||||
{
|
||||
"name": "timestamp1",
|
||||
"data_type": "timestamp"
|
||||
},
|
||||
{
|
||||
"name": "timestamp2",
|
||||
"data_type": "timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "interval1",
|
||||
"data_type": "interval"
|
||||
},
|
||||
{
|
||||
"name": "array1",
|
||||
"data_type": "_text"
|
||||
},
|
||||
{
|
||||
"name": "jsondata",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "jsondata2",
|
||||
"data_type": "json"
|
||||
},
|
||||
{
|
||||
"name": "uuidcolumn",
|
||||
"data_type": "uuid"
|
||||
},
|
||||
{
|
||||
"name": "ipaddress",
|
||||
"data_type": "inet"
|
||||
},
|
||||
{
|
||||
"name": "macaddress",
|
||||
"data_type": "macaddr"
|
||||
},
|
||||
{
|
||||
"name": "cidrrange",
|
||||
"data_type": "cidr"
|
||||
},
|
||||
{
|
||||
"name": "xmldata",
|
||||
"data_type": "142"
|
||||
},
|
||||
{
|
||||
"name": "currency",
|
||||
"data_type": "790"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"array1": "(408)-589-5841",
|
||||
@@ -41,13 +151,6 @@
|
||||
"uuidcolumn": "6948df80-14bd-4e04-8842-7668d9c001f5",
|
||||
"xmldata": "<book><title>Manual</title><chapter>...</chapter></book>"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 2523750,
|
||||
"scans": [],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,90 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "resource_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "mod_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "start_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "end_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "auto_generated",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "source_definition",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "is_anonymous",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "severity",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "width",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "sql",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "args",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "query",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "qualified_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "documentation",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "tags",
|
||||
"data_type": "jsonb"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"args": {
|
||||
@@ -33,13 +119,6 @@
|
||||
"type": null,
|
||||
"width": null
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 280292,
|
||||
"scans": [],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,74 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "resource_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "mod_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "start_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "end_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "auto_generated",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "source_definition",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "is_anonymous",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "sql",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "args",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "params",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "path",
|
||||
"data_type": "jsonb"
|
||||
},
|
||||
{
|
||||
"name": "qualified_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "description",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "documentation",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "tags",
|
||||
"data_type": "jsonb"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"args": null,
|
||||
@@ -39,13 +109,6 @@
|
||||
"tags": null,
|
||||
"title": "Sample query 1"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 311375,
|
||||
"scans": [],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"data_type": "int8"
|
||||
},
|
||||
{
|
||||
"name": "string_column",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "json_column",
|
||||
"data_type": "jsonb"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"id": 0,
|
||||
@@ -12,36 +26,6 @@
|
||||
},
|
||||
"string_column": "stringValuesomething-0"
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 51849333,
|
||||
"scans": [
|
||||
{
|
||||
"connection": "chaos",
|
||||
"table": "chaos_all_column_types",
|
||||
"cache_hit": false,
|
||||
"rows_fetched": 100,
|
||||
"hydrate_calls": 100,
|
||||
"start_time": "2024-04-11T11:53:34+05:30",
|
||||
"duration": 13,
|
||||
"columns": [
|
||||
"id",
|
||||
"string_column",
|
||||
"json_column"
|
||||
],
|
||||
"limit": null,
|
||||
"quals": [
|
||||
{
|
||||
"column": "id",
|
||||
"operator": "=",
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 100,
|
||||
"hydrate_calls": 100
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,11 +1,70 @@
|
||||
{
|
||||
"rows": [],
|
||||
"metadata": {
|
||||
"Duration": 377083,
|
||||
"scans": [],
|
||||
"rows_returned": 0,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
"columns": [
|
||||
{
|
||||
"name": "name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "state",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "connections",
|
||||
"data_type": "_text"
|
||||
},
|
||||
{
|
||||
"name": "import_schema",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "error",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "plugin",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "plugin_instance",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "schema_mode",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "schema_hash",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "comments_set",
|
||||
"data_type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "connection_mod_time",
|
||||
"data_type": "timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "plugin_mod_time",
|
||||
"data_type": "timestamptz"
|
||||
},
|
||||
{
|
||||
"name": "file_name",
|
||||
"data_type": "text"
|
||||
},
|
||||
{
|
||||
"name": "start_line_number",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "end_line_number",
|
||||
"data_type": "int4"
|
||||
}
|
||||
],
|
||||
"rows": []
|
||||
}
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"name": "val",
|
||||
"data_type": "int4"
|
||||
},
|
||||
{
|
||||
"name": "col",
|
||||
"data_type": "int4"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"col": 2,
|
||||
"val": 1
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"Duration": 149041,
|
||||
"scans": [],
|
||||
"rows_returned": 1,
|
||||
"rows_fetched": 0,
|
||||
"hydrate_calls": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "select from chaos.chaos_high_column_count order by column_0" {
|
||||
skip
|
||||
run steampipe query --output json "select * from chaos.chaos_high_column_count order by column_0 limit 10"
|
||||
echo $output > $TEST_DATA_DIR/actual_1.json
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "steampipe check - export snapshot" {
|
||||
skip "deprecated"
|
||||
cd $CONTROL_RENDERING_TEST_MOD
|
||||
run steampipe check control.sample_control_mixed_results_1 --export test.sps --progress=false
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ load "$LIB_BATS_ASSERT/load.bash"
|
||||
load "$LIB_BATS_SUPPORT/load.bash"
|
||||
|
||||
@test "simple dashboard test" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.sibling_containers_report --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_sibling_containers"
|
||||
|
||||
@@ -19,6 +20,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard with 'with' blocks" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.testing_with_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_withs"
|
||||
|
||||
@@ -40,6 +42,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard with 'text' blocks" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.testing_text_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_texts"
|
||||
|
||||
@@ -57,6 +60,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard with 'card' blocks" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.testing_card_blocks --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_cards"
|
||||
|
||||
@@ -75,6 +79,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard with node and edge blocks" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.testing_nodes_and_edges --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_graphs"
|
||||
|
||||
@@ -96,6 +101,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard with 'input' and test --dashboard-input arg" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.testing_dashboard_inputs --export test.sps --output none --mod-location "$FILE_PATH/test_data/mods/dashboard_inputs" --dashboard-input new_input=test
|
||||
|
||||
@@ -113,6 +119,7 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
}
|
||||
|
||||
@test "dashboard input with base" {
|
||||
skip "deprecated"
|
||||
# run a dashboard and shapshot the output
|
||||
run steampipe dashboard dashboard.resource_details --export test.sps --output none --mod-location "$FILE_PATH/test_data/dashboard_inputs_with_base"
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
steampipe query "select * from steampipe_query" --output json > output.json
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 9th line, since it contains file location which would differ in github runners
|
||||
# removing the 79th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "9d" output.json
|
||||
run sed -i ".json" "79d" output.json
|
||||
else
|
||||
run sed -i "9d" output.json
|
||||
run sed -i "79d" output.json
|
||||
fi
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_query.json" output.json
|
||||
@@ -39,11 +39,11 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
steampipe query "select * from steampipe_control" --output json > output.json
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 12th line, since it contains file location which would differ in github runners
|
||||
# removing the 98th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "12d" output.json
|
||||
run sed -i ".json" "98d" output.json
|
||||
else
|
||||
run sed -i "12d" output.json
|
||||
run sed -i "98d" output.json
|
||||
fi
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_control.json" output.json
|
||||
@@ -57,377 +57,379 @@ load "$LIB_BATS_SUPPORT/load.bash"
|
||||
rm -f output.json
|
||||
}
|
||||
|
||||
@test "resource=variable | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_variable" --output json > output.json
|
||||
# re-enable the following tests if needed after steampipe cmd deprecations
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 8th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "9d" output.json
|
||||
run sed -i ".json" "34d" output.json
|
||||
else
|
||||
run sed -i "9d" output.json
|
||||
run sed -i "34d" output.json
|
||||
fi
|
||||
# @test "resource=variable | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_variable" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_variable.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 8th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "9d" output.json
|
||||
# run sed -i ".json" "34d" output.json
|
||||
# else
|
||||
# run sed -i "9d" output.json
|
||||
# run sed -i "34d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_variable.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=benchmark | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_benchmark" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 11th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "11d" output.json
|
||||
else
|
||||
run sed -i "11d" output.json
|
||||
fi
|
||||
# @test "resource=benchmark | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_benchmark" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_benchmark.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 11th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "11d" output.json
|
||||
# else
|
||||
# run sed -i "11d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_benchmark.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 12th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "12d" output.json
|
||||
else
|
||||
run sed -i "12d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 12th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "12d" output.json
|
||||
# else
|
||||
# run sed -i "12d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_card | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_card" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 8th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "9d" output.json
|
||||
else
|
||||
run sed -i "9d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_card | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_card" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_card.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 8th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "9d" output.json
|
||||
# else
|
||||
# run sed -i "9d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_card.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_image | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_image" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 10th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "10d" output.json
|
||||
else
|
||||
run sed -i "10d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_image | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_image" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_image.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 10th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "10d" output.json
|
||||
# else
|
||||
# run sed -i "10d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_image.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_text | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_text" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 8th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "8d" output.json
|
||||
else
|
||||
run sed -i "8d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_text | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_text" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_text.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 8th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "8d" output.json
|
||||
# else
|
||||
# run sed -i "8d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_text.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_chart | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_chart" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 10th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "10d" output.json
|
||||
else
|
||||
run sed -i "10d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_chart | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_chart" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_chart.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 10th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "10d" output.json
|
||||
# else
|
||||
# run sed -i "10d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_chart.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_flow | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_flow" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 14th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "14d" output.json
|
||||
else
|
||||
run sed -i "14d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_flow | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_flow" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_flow.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 14th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "14d" output.json
|
||||
# else
|
||||
# run sed -i "14d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_flow.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_graph | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_graph" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 15th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "15d" output.json
|
||||
else
|
||||
run sed -i "15d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_graph | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_graph" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_graph.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 15th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "15d" output.json
|
||||
# else
|
||||
# run sed -i "15d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_graph.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_hierarchy | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_hierarchy" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 14th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "14d" output.json
|
||||
else
|
||||
run sed -i "14d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_hierarchy | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_hierarchy" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_hierarchy.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 14th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "14d" output.json
|
||||
# else
|
||||
# run sed -i "14d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_hierarchy.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_input | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_input" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 10th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "10d" output.json
|
||||
else
|
||||
run sed -i "10d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_input | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_input" --output json > output.json
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_input.json" output.json
|
||||
echo $output
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 10th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "10d" output.json
|
||||
# else
|
||||
# run sed -i "10d" output.json
|
||||
# fi
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_input.json" output.json
|
||||
# echo $output
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
@test "resource=dashboard_table | steampipe_introspection=info" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=info
|
||||
steampipe query "select * from steampipe_dashboard_table" --output json > output.json
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 10th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "10d" output.json
|
||||
else
|
||||
run sed -i "10d" output.json
|
||||
fi
|
||||
# @test "resource=dashboard_table | steampipe_introspection=info" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=info
|
||||
# steampipe query "select * from steampipe_dashboard_table" --output json > output.json
|
||||
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 10th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "10d" output.json
|
||||
# else
|
||||
# run sed -i "10d" output.json
|
||||
# fi
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_table.json" output.json
|
||||
echo $output
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_dashboard_table.json" output.json
|
||||
# echo $output
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
@test "ensure mod name in introspection table is <mod_name> not mod.<mod_name>" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
run steampipe query "select * from steampipe_query" --output json
|
||||
# @test "ensure mod name in introspection table is <mod_name> not mod.<mod_name>" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# run steampipe query "select * from steampipe_query" --output json
|
||||
|
||||
# extract the first mod_name from the list
|
||||
mod_name=$(echo $output | jq '.rows[0].mod_name')
|
||||
# # extract the first mod_name from the list
|
||||
# mod_name=$(echo $output | jq '.rows[0].mod_name')
|
||||
|
||||
# check if mod_name starts with "mod."
|
||||
if [[ "$mod_name" == *"mod."* ]];
|
||||
then
|
||||
flag=1
|
||||
else
|
||||
flag=0
|
||||
fi
|
||||
assert_equal "$flag" "0"
|
||||
}
|
||||
# # check if mod_name starts with "mod."
|
||||
# if [[ "$mod_name" == *"mod."* ]];
|
||||
# then
|
||||
# flag=1
|
||||
# else
|
||||
# flag=0
|
||||
# fi
|
||||
# assert_equal "$flag" "0"
|
||||
# }
|
||||
|
||||
@test "ensure query pseudo resources, i.e. sql files, have resource name <query_name> not <query.query_name>" {
|
||||
cd $WORKSPACE_DIR
|
||||
run steampipe query "select * from steampipe_query" --output json
|
||||
# @test "ensure query pseudo resources, i.e. sql files, have resource name <query_name> not <query.query_name>" {
|
||||
# cd $WORKSPACE_DIR
|
||||
# run steampipe query "select * from steampipe_query" --output json
|
||||
|
||||
# extract the first encountered sql file's file_name from the list
|
||||
sql_file_name=$(echo $output | jq '.rows[0].file_name' | grep ".sql" | head -1)
|
||||
# # extract the first encountered sql file's file_name from the list
|
||||
# sql_file_name=$(echo $output | jq '.rows[0].file_name' | grep ".sql" | head -1)
|
||||
|
||||
#extract the resource_name of the above extracted file_name
|
||||
resource_name=$(echo $output | jq --arg FILENAME "$sql_file_name" '.rows[0] | select(.file_name=="$FILENAME") | .resource_name')
|
||||
# #extract the resource_name of the above extracted file_name
|
||||
# resource_name=$(echo $output | jq --arg FILENAME "$sql_file_name" '.rows[0] | select(.file_name=="$FILENAME") | .resource_name')
|
||||
|
||||
# check if resource_name starts with "query."
|
||||
if [[ "$resource_name" == *"query."* ]];
|
||||
then
|
||||
flag=1
|
||||
else
|
||||
flag=0
|
||||
fi
|
||||
assert_equal "$flag" "0"
|
||||
}
|
||||
# # check if resource_name starts with "query."
|
||||
# if [[ "$resource_name" == *"query."* ]];
|
||||
# then
|
||||
# flag=1
|
||||
# else
|
||||
# flag=0
|
||||
# fi
|
||||
# assert_equal "$flag" "0"
|
||||
# }
|
||||
|
||||
@test "ensure the reference_from column is populated correctly" {
|
||||
skip
|
||||
cd $SIMPLE_MOD_DIR
|
||||
run steampipe query "select * from steampipe_reference" --output json
|
||||
# @test "ensure the reference_from column is populated correctly" {
|
||||
# skip
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# run steampipe query "select * from steampipe_reference" --output json
|
||||
|
||||
# extract the refs and the referenced_by of the variable `sample_var_1`
|
||||
refs=$(echo $output | jq '.rows[0] | select(.reference_to=="var.sample_var_1") | .reference_from')
|
||||
echo $refs
|
||||
# # extract the refs and the referenced_by of the variable `sample_var_1`
|
||||
# refs=$(echo $output | jq '.rows[0] | select(.reference_to=="var.sample_var_1") | .reference_from')
|
||||
# echo $refs
|
||||
|
||||
assert_equal "$refs" '"query.sample_query_1"'
|
||||
}
|
||||
# assert_equal "$refs" '"query.sample_query_1"'
|
||||
# }
|
||||
|
||||
@test "introspection tables should get populated in query batch mode" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
run steampipe query "select * from steampipe_query" --output json
|
||||
# @test "introspection tables should get populated in query batch mode" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# run steampipe query "select * from steampipe_query" --output json
|
||||
|
||||
# extracting only description from the list, which is enough to prove that there is an output
|
||||
description=$(echo $output | jq '.rows[0].description')
|
||||
assert_equal "$description" '"query 1 - 3 params all with defaults"'
|
||||
}
|
||||
# # extracting only description from the list, which is enough to prove that there is an output
|
||||
# description=$(echo $output | jq '.rows[0].description')
|
||||
# assert_equal "$description" '"query 1 - 3 params all with defaults"'
|
||||
# }
|
||||
|
||||
@test "steampipe_introspection=control" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
export STEAMPIPE_INTROSPECTION=control
|
||||
steampipe query "select * from steampipe_control" --output json > output.json
|
||||
# @test "steampipe_introspection=control" {
|
||||
# cd $SIMPLE_MOD_DIR
|
||||
# export STEAMPIPE_INTROSPECTION=control
|
||||
# steampipe query "select * from steampipe_control" --output json > output.json
|
||||
|
||||
# checking for OS type, since sed command is different for linux and OSX
|
||||
# removing the 12th line, since it contains file location which would differ in github runners
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
run sed -i ".json" "12d" output.json
|
||||
else
|
||||
run sed -i "12d" output.json
|
||||
fi
|
||||
# # checking for OS type, since sed command is different for linux and OSX
|
||||
# # removing the 12th line, since it contains file location which would differ in github runners
|
||||
# if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# run sed -i ".json" "12d" output.json
|
||||
# else
|
||||
# run sed -i "12d" output.json
|
||||
# fi
|
||||
|
||||
run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_control.json" output.json
|
||||
echo $output
|
||||
# run jd -f patch "$TEST_DATA_DIR/expected_introspection_info_control.json" output.json
|
||||
# echo $output
|
||||
|
||||
diff=$($FILE_PATH/json_patch.sh $output)
|
||||
echo $diff
|
||||
# diff=$($FILE_PATH/json_patch.sh $output)
|
||||
# echo $diff
|
||||
|
||||
# check if there is no diff returned by the script
|
||||
assert_equal "$diff" ""
|
||||
rm -f output.json
|
||||
}
|
||||
# # check if there is no diff returned by the script
|
||||
# assert_equal "$diff" ""
|
||||
# rm -f output.json
|
||||
# }
|
||||
|
||||
@test "steampipe check --where | steampipe_introspection=control" {
|
||||
cd $SIMPLE_MOD_DIR
|
||||
|
||||
Reference in New Issue
Block a user