github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/workspace/workspace_test.go (about)

     1  package workspace
     2  
     3  // Testing the runtime dependencies(dashboards) for workspaces
     4  //
     5  //type loadWorkspaceTest struct {
     6  //	skip                        bool
     7  //	source                      string
     8  //	expected                    interface{}
     9  //	expectedRuntimeDependencies map[string]map[string]*modconfig.RuntimeDependency
    10  //}
    11  //
    12  //var toStringPointer = utils.ToStringPointer
    13  //var toIntegerPointer = utils.ToIntegerPointer
    14  //
    15  //var testCasesLoadWorkspace = map[string]loadWorkspaceTest{
    16  //	"dashboard_runtime_deps_named_arg": { // this is to test runtime dependencies for named arguments
    17  //		skip:   true,
    18  //		source: "test_data/dashboard_runtime_deps_named_arg",
    19  //		expected: &Workspace{
    20  //			Mod: &modconfig.Mod{
    21  //				ShortName:   "dashboard_runtime_deps_named_arg",
    22  //				FullName:    "mod.dashboard_runtime_deps_named_arg",
    23  //				Require:     &modconfig.Require{},
    24  //				Description: toStringPointer("this mod is to test runtime dependencies for named arguments"),
    25  //				Title:       toStringPointer("dashboard runtime dependencies named arguments"),
    26  //				ResourceMaps: &modconfig.ResourceMaps{
    27  //					Queries: map[string]*modconfig.Query{
    28  //						"dashboard_runtime_deps_named_arg.query.query1": {
    29  //							FullName:        "dashboard_runtime_deps_named_arg.query.query1",
    30  //							ShortName:       "query1",
    31  //							UnqualifiedName: "query.query1",
    32  //							SQL:             toStringPointer("select 1 as query1"),
    33  //						},
    34  //						"dashboard_runtime_deps_named_arg.query.query2": {
    35  //							FullName:        "dashboard_runtime_deps_named_arg.query.query2",
    36  //							ShortName:       "query2",
    37  //							UnqualifiedName: "query.query2",
    38  //							SQL:             toStringPointer("select 2 as query2"),
    39  //						},
    40  //					},
    41  //					Dashboards: map[string]*modconfig.Dashboard{
    42  //						"dashboard_runtime_deps_named_arg.dashboard.dashboard_named_args": {
    43  //							FullName:        "dashboard_runtime_deps_named_arg.dashboard.dashboard_named_args",
    44  //							ShortName:       "dashboard_named_args",
    45  //							UnqualifiedName: "dashboard.dashboard_named_args",
    46  //							Title:           toStringPointer("dashboard with named arguments"),
    47  //							ChildNames:      []string{"dashboard_runtime_deps_named_arg.input.user", "dashboard_runtime_deps_named_arg.table.dashboard_dashboard_named_args_anonymous_table_0"},
    48  //							//HclType:         "dashboard",
    49  //						},
    50  //					},
    51  //					DashboardInputs: map[string]map[string]*modconfig.DashboardInput{
    52  //						"dashboard_runtime_deps_named_arg.dashboard.dashboard_named_args": {
    53  //							"dashboard_runtime_deps_named_arg.input.user": {
    54  //								FullName:        "dashboard_runtime_deps_named_arg.input.user",
    55  //								ShortName:       "user",
    56  //								UnqualifiedName: "input.user",
    57  //								DashboardName:   "dashboard_runtime_deps_named_arg.dashboard.dashboard_named_args",
    58  //								Title:           toStringPointer("AWS IAM User"),
    59  //								Width:           toIntegerPointer(4),
    60  //								SQL:             toStringPointer("select 1 as query1"),
    61  //							},
    62  //						},
    63  //					},
    64  //					DashboardTables: map[string]*modconfig.DashboardTable{
    65  //						"dashboard_runtime_deps_named_arg.table.dashboard_dashboard_named_args_anonymous_table_0": {
    66  //							FullName:        "dashboard_runtime_deps_named_arg.table.dashboard_dashboard_named_args_anonymous_table_0",
    67  //							ShortName:       "dashboard_dashboard_named_args_anonymous_table_0",
    68  //							UnqualifiedName: "table.dashboard_dashboard_named_args_anonymous_table_0",
    69  //							ColumnList: modconfig.DashboardTableColumnList{
    70  //								&modconfig.DashboardTableColumn{
    71  //									Name:    "depth",
    72  //									Display: toStringPointer("none"),
    73  //								},
    74  //							},
    75  //							Columns: map[string]*modconfig.DashboardTableColumn{
    76  //								"depth": {
    77  //									Name:    "depth",
    78  //									Display: toStringPointer("none"),
    79  //								},
    80  //							},
    81  //							Query: &modconfig.Query{
    82  //								ShortName: "query2",
    83  //								FullName:  "dashboard_runtime_deps_named_arg.query.query2",
    84  //								SQL:       toStringPointer("select 2 as query2"),
    85  //							},
    86  //							Args: &modconfig.QueryArgs{},
    87  //						},
    88  //					},
    89  //					References: map[string]*modconfig.ResourceReference{
    90  //						"To: query.query1\nFrom: input.user\nBlockType: input\nBlockName: user\nAttribute: sql": {
    91  //							To:        "query.query1",
    92  //							From:      "input.user",
    93  //							BlockType: "input",
    94  //							BlockName: "user",
    95  //							Attribute: "sql",
    96  //						},
    97  //						"To: query.query2\nFrom: table.dashboard_dashboard_named_args_anonymous_table_0\nBlockType: table\nBlockName: \nAttribute: query": {
    98  //							To:        "query.query2",
    99  //							From:      "table.dashboard_dashboard_named_args_anonymous_table_0",
   100  //							BlockType: "table",
   101  //							BlockName: "",
   102  //							Attribute: "query",
   103  //						},
   104  //						"To: self.input.user\nFrom: table.dashboard_dashboard_named_args_anonymous_table_0\nBlockType: table\nBlockName: \nAttribute: args": {
   105  //							To:        "self.input.user",
   106  //							From:      "table.dashboard_dashboard_named_args_anonymous_table_0",
   107  //							BlockType: "table",
   108  //							BlockName: "",
   109  //							Attribute: "args",
   110  //						},
   111  //					},
   112  //				},
   113  //			},
   114  //		},
   115  //		expectedRuntimeDependencies: map[string]map[string]*modconfig.RuntimeDependency{
   116  //			"dashboard_runtime_deps_named_arg.table.dashboard_dashboard_named_args_anonymous_table_0": {
   117  //				"arg.iam_user_arn->self.input.user.value": {
   118  //					PropertyPath: &modconfig.ParsedPropertyPath{
   119  //						PropertyPath: []string{"value"},
   120  //					},
   121  //					SourceResourceName: &modconfig.DashboardInput{
   122  //						FullName: "dashboard_runtime_deps_named_arg.input.user",
   123  //					},
   124  //				},
   125  //			},
   126  //		},
   127  //	},
   128  //	"dashboard_runtime_deps_pos_arg": { // this is to test runtime dependencies for positional arguments
   129  //		skip:   true,
   130  //		source: "test_data/dashboard_runtime_deps_pos_arg",
   131  //		expected: &Workspace{
   132  //			Mod: &modconfig.Mod{
   133  //				ShortName:   "dashboard_runtime_deps_pos_arg",
   134  //				FullName:    "mod.dashboard_runtime_deps_pos_arg",
   135  //				Require:     &modconfig.Require{},
   136  //				Description: toStringPointer("this mod is to test runtime dependencies for positional arguments"),
   137  //				Title:       toStringPointer("dashboard runtime dependencies positional arguments"),
   138  //				ResourceMaps: &modconfig.ResourceMaps{
   139  //					Queries: map[string]*modconfig.Query{
   140  //						"dashboard_runtime_deps_pos_arg.query.query1": {
   141  //							FullName:  "dashboard_runtime_deps_pos_arg.query.query1",
   142  //							ShortName: "query1",
   143  //							SQL:       toStringPointer("select 1 as query1"),
   144  //						},
   145  //						"dashboard_runtime_deps_pos_arg.query.query2": {
   146  //							FullName:  "dashboard_runtime_deps_pos_arg.query.query2",
   147  //							ShortName: "query2",
   148  //							SQL:       toStringPointer("select 2 as query2"),
   149  //						},
   150  //					},
   151  //					Dashboards: map[string]*modconfig.Dashboard{
   152  //						"dashboard_runtime_deps_pos_arg.dashboard.dashboard_pos_args": {
   153  //							FullName:        "dashboard_runtime_deps_pos_arg.dashboard.dashboard_pos_args",
   154  //							ShortName:       "dashboard_pos_args",
   155  //							UnqualifiedName: "dashboard.dashboard_pos_args",
   156  //							Title:           toStringPointer("dashboard with positional arguments"),
   157  //							ChildNames:      []string{"dashboard_runtime_deps_pos_arg.input.user", "dashboard_runtime_deps_pos_arg.table.dashboard_dashboard_pos_args_anonymous_table_0"},
   158  //							//HclType:         "dashboard",
   159  //						},
   160  //					},
   161  //					DashboardInputs: map[string]map[string]*modconfig.DashboardInput{
   162  //						"dashboard_runtime_deps_pos_arg.dashboard.dashboard_pos_args": {
   163  //							"dashboard_runtime_deps_pos_arg.input.user": {
   164  //								FullName:        "dashboard_runtime_deps_pos_arg.input.user",
   165  //								ShortName:       "user",
   166  //								UnqualifiedName: "input.user",
   167  //								DashboardName:   "dashboard_runtime_deps_pos_arg.dashboard.dashboard_pos_args",
   168  //								Title:           toStringPointer("AWS IAM User"),
   169  //								Width:           toIntegerPointer(4),
   170  //								SQL:             toStringPointer("select 1 as query1"),
   171  //							},
   172  //						},
   173  //					},
   174  //					DashboardTables: map[string]*modconfig.DashboardTable{
   175  //						"dashboard_runtime_deps_pos_arg.table.dashboard_dashboard_pos_args_anonymous_table_0": {
   176  //							FullName:        "dashboard_runtime_deps_pos_arg.table.dashboard_dashboard_pos_args_anonymous_table_0",
   177  //							ShortName:       "dashboard_dashboard_pos_args_anonymous_table_0",
   178  //							UnqualifiedName: "table.dashboard_dashboard_pos_args_anonymous_table_0",
   179  //							ColumnList: modconfig.DashboardTableColumnList{
   180  //								&modconfig.DashboardTableColumn{
   181  //									Name:    "depth",
   182  //									Display: toStringPointer("none"),
   183  //								},
   184  //							},
   185  //							Columns: map[string]*modconfig.DashboardTableColumn{
   186  //								"depth": {
   187  //									Name:    "depth",
   188  //									Display: toStringPointer("none"),
   189  //								},
   190  //							},
   191  //							Query: &modconfig.Query{
   192  //								ShortName: "query2",
   193  //								FullName:  "dashboard_runtime_deps_pos_arg.query.query2",
   194  //								SQL:       toStringPointer("select 2 as query2"),
   195  //							},
   196  //							Args: &modconfig.QueryArgs{
   197  //								ArgList: []*string{nil},
   198  //							},
   199  //						},
   200  //					},
   201  //					References: map[string]*modconfig.ResourceReference{
   202  //						"To: query.query1\nFrom: input.user\nBlockType: input\nBlockName: user\nAttribute: sql": {
   203  //							To:        "query.query1",
   204  //							From:      "input.user",
   205  //							BlockType: "input",
   206  //							BlockName: "user",
   207  //							Attribute: "sql",
   208  //						},
   209  //						"To: query.query2\nFrom: table.dashboard_dashboard_pos_args_anonymous_table_0\nBlockType: table\nBlockName: \nAttribute: query": {
   210  //							To:        "query.query2",
   211  //							From:      "table.dashboard_dashboard_pos_args_anonymous_table_0",
   212  //							BlockType: "table",
   213  //							BlockName: "",
   214  //							Attribute: "query",
   215  //						},
   216  //						"To: self.input.user\nFrom: table.dashboard_dashboard_pos_args_anonymous_table_0\nBlockType: table\nBlockName: \nAttribute: args": {
   217  //							To:        "self.input.user",
   218  //							From:      "table.dashboard_dashboard_pos_args_anonymous_table_0",
   219  //							BlockType: "table",
   220  //							BlockName: "",
   221  //							Attribute: "args",
   222  //						},
   223  //					},
   224  //				},
   225  //			},
   226  //		},
   227  //		expectedRuntimeDependencies: map[string]map[string]*modconfig.RuntimeDependency{
   228  //			"dashboard_runtime_deps_pos_arg.table.dashboard_dashboard_pos_args_anonymous_table_0": {
   229  //				"arg.0->self.input.user.value": {
   230  //					PropertyPath: &modconfig.ParsedPropertyPath{
   231  //						PropertyPath: []string{"value"},
   232  //					},
   233  //					SourceResourceName: &modconfig.DashboardInput{
   234  //						FullName: "dashboard_runtime_deps_pos_arg.input.user",
   235  //					},
   236  //				},
   237  //			},
   238  //		},
   239  //	},
   240  //	"dependent_mod": {
   241  //		source: "test_data/dependent_mod",
   242  //		expected: &Workspace{
   243  //			Mod: &modconfig.Mod{
   244  //				ShortName: "local",
   245  //				FullName:  "mod.local",
   246  //				Title:     toStringPointer("dependent_mod"),
   247  //				Require:   &modconfig.Require{},
   248  //				ResourceMaps: &modconfig.ResourceMaps{
   249  //					Queries: map[string]*modconfig.Query{
   250  //						"m1.query.m1_q1": {
   251  //							ShortName:       "m1_q1",
   252  //							FullName:        "m1.query.m1_q1",
   253  //							SQL:             toStringPointer("select 1 as query"),
   254  //							UnqualifiedName: "query.m1_q1",
   255  //						},
   256  //					},
   257  //					Dashboards: map[string]*modconfig.Dashboard{
   258  //						"m1.dashboard.m1_d1": {
   259  //							ShortName:       "m1_d1",
   260  //							FullName:        "m1.dashboard.m1_d1",
   261  //							UnqualifiedName: "dashboard.m1_d1",
   262  //							Title:           toStringPointer("dashboard d1"),
   263  //							ChildNames:      []string{"m1.chart.dashboard_m1_d1_anonymous_chart_0", "m1.input.i1"},
   264  //							//HclType:         "dashboard",
   265  //						},
   266  //						"local.dashboard.local_d1": {
   267  //							ShortName:       "local_d1",
   268  //							FullName:        "local.dashboard.local_d1",
   269  //							UnqualifiedName: "dashboard.local_d1",
   270  //							Title:           toStringPointer("dashboard d1"),
   271  //							ChildNames:      []string{"local.chart.dashboard_local_d1_anonymous_chart_0", "local.input.i1"},
   272  //						},
   273  //					},
   274  //					DashboardCharts: map[string]*modconfig.DashboardChart{
   275  //						"m1.chart.global_chart": {
   276  //							FullName:        "m1.chart.global_chart",
   277  //							ShortName:       "global_chart",
   278  //							UnqualifiedName: "chart.global_chart",
   279  //							Title:           toStringPointer("chart global m1_c1"),
   280  //							SQL:             toStringPointer("select 'm1_global_c1' as chart"),
   281  //						},
   282  //						"m1.chart.dashboard_m1_d1_anonymous_chart_0": {
   283  //							FullName:        "m1.chart.dashboard_m1_d1_anonymous_chart_0",
   284  //							ShortName:       "dashboard_m1_d1_anonymous_chart_0",
   285  //							UnqualifiedName: "chart.dashboard_m1_d1_anonymous_chart_0",
   286  //							Title:           toStringPointer("chart c1"),
   287  //							SQL:             toStringPointer("select 'm1_d1_c1' as chart"),
   288  //						},
   289  //						"local.chart.chart1": {
   290  //							FullName:        "local.chart.chart1",
   291  //							ShortName:       "chart1",
   292  //							UnqualifiedName: "chart.chart1",
   293  //							Title:           toStringPointer("chart 1"),
   294  //							Query: &modconfig.Query{
   295  //								FullName:  "m1.query.m1_q1",
   296  //								ShortName: "m1_q1",
   297  //								SQL:       toStringPointer("select 1 as query"),
   298  //							},
   299  //						},
   300  //						"local.chart.dashboard_local_d1_anonymous_chart_0": {
   301  //							FullName:        "local.chart.dashboard_local_d1_anonymous_chart_0",
   302  //							ShortName:       "dashboard_local_d1_anonymous_chart_0",
   303  //							UnqualifiedName: "chart.dashboard_local_d1_anonymous_chart_0",
   304  //							Title:           toStringPointer("chart global m1_c1"),
   305  //							SQL:             toStringPointer("select 'm1_global_c1' as chart"),
   306  //						},
   307  //					},
   308  //					DashboardInputs: map[string]map[string]*modconfig.DashboardInput{
   309  //						"m1.dashboard.m1_d1": {
   310  //							"m1.input.i1": {
   311  //								FullName:        "m1.input.i1",
   312  //								ShortName:       "i1",
   313  //								UnqualifiedName: "input.i1",
   314  //								DashboardName:   "m1.dashboard.m1_d1",
   315  //								Title:           toStringPointer("input i1"),
   316  //							},
   317  //						},
   318  //						"local.dashboard.local_d1": {
   319  //							"local.input.i1": {
   320  //								FullName:        "local.input.i1",
   321  //								ShortName:       "i1",
   322  //								UnqualifiedName: "input.i1",
   323  //								DashboardName:   "local.dashboard.local_d1",
   324  //								Title:           toStringPointer("global input m1_i1"),
   325  //							},
   326  //						},
   327  //					},
   328  //					GlobalDashboardInputs: map[string]*modconfig.DashboardInput{
   329  //						"m1.input.global_input": {
   330  //							FullName:        "m1.input.global_input",
   331  //							ShortName:       "global_input",
   332  //							UnqualifiedName: "input.global_input",
   333  //							DashboardName:   "",
   334  //							Title:           toStringPointer("global input m1_i1"),
   335  //						},
   336  //					},
   337  //					References: map[string]*modconfig.ResourceReference{
   338  //						"To: m1.query.m1_q1\nFrom: chart.chart1\nBlockType: chart\nBlockName: chart1\nAttribute: query": {
   339  //							To:        "m1.query.m1_q1",
   340  //							From:      "chart.chart1",
   341  //							BlockType: "chart",
   342  //							BlockName: "chart1",
   343  //							Attribute: "query",
   344  //						},
   345  //						"To: m1.chart.global_chart\nFrom: chart.dashboard_local_d1_anonymous_chart_0\nBlockType: chart\nBlockName: \nAttribute: base": {
   346  //							To:        "m1.chart.global_chart",
   347  //							From:      "chart.dashboard_local_d1_anonymous_chart_0",
   348  //							BlockType: "chart",
   349  //							BlockName: "",
   350  //							Attribute: "base",
   351  //						},
   352  //						"To: m1.input.global_input\nFrom: input.i1\nBlockType: input\nBlockName: i1\nAttribute: base": {
   353  //							To:        "m1.input.global_input",
   354  //							From:      "input.i1",
   355  //							BlockType: "input",
   356  //							BlockName: "i1",
   357  //							Attribute: "base",
   358  //						},
   359  //					},
   360  //				},
   361  //			},
   362  //		},
   363  //		expectedRuntimeDependencies: map[string]map[string]*modconfig.RuntimeDependency{},
   364  //	},
   365  //	"dependent_mod_2": {
   366  //		skip:   true,
   367  //		source: "test_data/dependent_mod_2",
   368  //		expected: &Workspace{
   369  //			Mod: &modconfig.Mod{
   370  //				ShortName: "local",
   371  //				FullName:  "mod.local",
   372  //				Title:     toStringPointer("dependent_mod"),
   373  //				Require:   &modconfig.Require{},
   374  //				ResourceMaps: &modconfig.ResourceMaps{
   375  //					Queries: map[string]*modconfig.Query{
   376  //						"m1.query.m1_q1": {
   377  //							ShortName:       "m1_q1",
   378  //							FullName:        "m1.query.m1_q1",
   379  //							SQL:             toStringPointer("select 1 as query"),
   380  //							UnqualifiedName: "query.m1_q1",
   381  //						},
   382  //					},
   383  //					Dashboards: map[string]*modconfig.Dashboard{
   384  //						"m1.dashboard.m1_d1": {
   385  //							ShortName:       "m1_d1",
   386  //							FullName:        "m1.dashboard.m1_d1",
   387  //							UnqualifiedName: "dashboard.m1_d1",
   388  //							Title:           toStringPointer("dashboard d1"),
   389  //							ChildNames:      []string{"m1.chart.dashboard_m1_d1_anonymous_chart_0", "m1.input.i1"},
   390  //							//HclType:         "dashboard",
   391  //						},
   392  //						"local.dashboard.local_d1": {
   393  //							ShortName:       "local_d1",
   394  //							FullName:        "local.dashboard.local_d1",
   395  //							UnqualifiedName: "dashboard.local_d1",
   396  //							Title:           toStringPointer("dashboard d1"),
   397  //							ChildNames:      []string{"m1.input.i1", "m1.chart.dashboard_m1_d1_anonymous_chart_0", "m1.input.i1"},
   398  //						},
   399  //					},
   400  //					DashboardCharts: map[string]*modconfig.DashboardChart{
   401  //						"m1.chart.global_chart": {
   402  //							FullName:        "m1.chart.global_chart",
   403  //							ShortName:       "global_chart",
   404  //							UnqualifiedName: "chart.global_chart",
   405  //							Title:           toStringPointer("chart global m1_c1"),
   406  //							SQL:             toStringPointer("select 'm1_global_c1' as chart"),
   407  //						},
   408  //						"m1.chart.dashboard_m1_d1_anonymous_chart_0": {
   409  //							FullName:        "m1.chart.dashboard_m1_d1_anonymous_chart_0",
   410  //							ShortName:       "dashboard_m1_d1_anonymous_chart_0",
   411  //							UnqualifiedName: "chart.dashboard_m1_d1_anonymous_chart_0",
   412  //							Title:           toStringPointer("chart c1"),
   413  //							SQL:             toStringPointer("select 'm1_d1_c1' as chart"),
   414  //						},
   415  //					},
   416  //					DashboardInputs: map[string]map[string]*modconfig.DashboardInput{
   417  //						"m1.dashboard.m1_d1": {
   418  //							"m1.input.i1": {
   419  //								FullName:        "m1.input.i1",
   420  //								ShortName:       "i1",
   421  //								UnqualifiedName: "input.i1",
   422  //								DashboardName:   "m1.dashboard.m1_d1",
   423  //								Title:           toStringPointer("input i1"),
   424  //							},
   425  //						},
   426  //						"local.dashboard.local_d1": {
   427  //							"m1.input.i1": {
   428  //								FullName:        "m1.input.i1",
   429  //								ShortName:       "i1",
   430  //								UnqualifiedName: "input.i1",
   431  //								DashboardName:   "local.dashboard.local_d1",
   432  //								Title:           toStringPointer("input i1"),
   433  //							},
   434  //						},
   435  //					},
   436  //					GlobalDashboardInputs: map[string]*modconfig.DashboardInput{
   437  //						"m1.input.global_input": {
   438  //							FullName:        "m1.input.global_input",
   439  //							ShortName:       "global_input",
   440  //							UnqualifiedName: "input.global_input",
   441  //							DashboardName:   "",
   442  //							Title:           toStringPointer("global input m1_i1"),
   443  //						},
   444  //					},
   445  //					References: map[string]*modconfig.ResourceReference{
   446  //						"To: m1.dashboard.m1_d1\nFrom: dashboard.local_d1\nBlockType: dashboard\nBlockName: local_d1\nAttribute: base": {
   447  //							To:        "m1.dashboard.m1_d1",
   448  //							From:      "dashboard.local_d1",
   449  //							BlockType: "dashboard",
   450  //							BlockName: "local_d1",
   451  //							Attribute: "base",
   452  //						},
   453  //					},
   454  //				},
   455  //			},
   456  //		},
   457  //		expectedRuntimeDependencies: map[string]map[string]*modconfig.RuntimeDependency{},
   458  //	},
   459  //}
   460  //
   461  //func TestLoadWorkspace(t *testing.T) {
   462  //	wd, err := os.Getwd()
   463  //	if err != nil {
   464  //		t.Fatalf("%v", err)
   465  //		return
   466  //	}
   467  //	for name, test := range testCasesLoadWorkspace {
   468  //		if test.skip {
   469  //			continue
   470  //		}
   471  //		executeWorkspaceLoadTest(t, name, test, wd)
   472  //	}
   473  //}
   474  //
   475  //func executeWorkspaceLoadTest(t *testing.T, name string, test loadWorkspaceTest, wd string) {
   476  //	workspacePath, err := filepath.Abs(test.source)
   477  //	if err != nil {
   478  //		t.Errorf("failed to build absolute config filepath from %s", test.source)
   479  //	}
   480  //
   481  //	actualWorkspace, err := Load(context.Background(), workspacePath)
   482  //	if err != nil {
   483  //		if test.expected != "ERROR" {
   484  //			t.Errorf(`Test: '%s'' FAILED : unexpected error %v`, name, err)
   485  //		}
   486  //		return
   487  //	}
   488  //	if test.expected == "ERROR" {
   489  //		t.Errorf(`Test: '%s'' FAILED : expected error but did not get one`, name)
   490  //		return
   491  //	}
   492  //
   493  //	expectedWorkspace := test.expected.(*Workspace)
   494  //
   495  //	// ensure parents and children are set correctly in expected mod (this is normally done as part of decode)
   496  //	err = setChildren(expectedWorkspace.Mod)
   497  //	if err != nil {
   498  //		t.Fatalf(err.Error())
   499  //	}
   500  //	expectedWorkspace.Mod.BuildResourceTree(nil)
   501  //
   502  //	// check runtime deps
   503  //	expectedRuntimeDeps := test.expectedRuntimeDependencies
   504  //	flag := ValidateRuntimeDeps(t, actualWorkspace, expectedRuntimeDeps)
   505  //	if !flag {
   506  //		fmt.Printf("")
   507  //
   508  //		t.Errorf("Test: '%s'' FAILED due to runtime dependency mismatch", name)
   509  //	}
   510  //
   511  //	if !actualWorkspace.Mod.Equals(expectedWorkspace.Mod) {
   512  //		fmt.Printf("")
   513  //
   514  //		t.Errorf("Test: '%s'' FAILED.", name)
   515  //	}
   516  //}
   517  //
   518  //// try to resolve mod resource children using their child names
   519  //func setChildren(mod *modconfig.Mod) error {
   520  //	for _, benchmark := range mod.ResourceMaps.Benchmarks {
   521  //		for _, childName := range benchmark.ChildNames {
   522  //			parsed, _ := modconfig.ParseResourceName(childName.Name)
   523  //			child, found := modconfig.GetResource(mod, parsed)
   524  //			if !found {
   525  //				return fmt.Errorf("failed to resolve child %s", childName)
   526  //			}
   527  //			benchmark.Children = append(benchmark.Children, child.(modconfig.ModTreeItem))
   528  //		}
   529  //	}
   530  //	for _, container := range mod.ResourceMaps.DashboardContainers {
   531  //		var children []modconfig.ModTreeItem
   532  //		for _, childName := range container.ChildNames {
   533  //			parsed, _ := modconfig.ParseResourceName(childName)
   534  //			var child modconfig.HclResource
   535  //			var found bool
   536  //			if parsed.ItemType == "input" {
   537  //				child, found = modconfig.GetDashboardInput(mod, parsed.ToResourceName(), container.Name())
   538  //			} else {
   539  //				child, found = modconfig.GetResource(mod, parsed)
   540  //			}
   541  //			if !found {
   542  //				return fmt.Errorf("failed to resolve child %s", childName)
   543  //			}
   544  //			children = append(children, child.(modconfig.ModTreeItem))
   545  //		}
   546  //		container.SetChildren(children)
   547  //
   548  //	}
   549  //	for _, dashboard := range mod.ResourceMaps.Dashboards {
   550  //		var children []modconfig.ModTreeItem
   551  //		for _, childName := range dashboard.ChildNames {
   552  //			parsed, _ := modconfig.ParseResourceName(childName)
   553  //			var child modconfig.HclResource
   554  //			var found bool
   555  //			if parsed.ItemType == "input" {
   556  //				child, found = modconfig.GetDashboardInput(mod, childName, dashboard.Name())
   557  //			} else {
   558  //				child, found = modconfig.GetResource(mod, parsed)
   559  //			}
   560  //			if !found {
   561  //				return fmt.Errorf("failed to resolve child %s", childName)
   562  //			}
   563  //			children = append(children, child.(modconfig.ModTreeItem))
   564  //		}
   565  //		dashboard.SetChildren(children)
   566  //	}
   567  //	return nil
   568  //}
   569  //
   570  //func ValidateRuntimeDeps(t *testing.T, workspace *Workspace, expected map[string]map[string]*modconfig.RuntimeDependency) bool {
   571  //	mod := workspace.Mod
   572  //	for name, expectedDeps := range expected {
   573  //		parsedName, err := modconfig.ParseResourceName(name)
   574  //		if err != nil {
   575  //			t.Fatalf(err.Error())
   576  //		}
   577  //
   578  //		resource, found := modconfig.GetResource(mod, parsedName)
   579  //		if !found {
   580  //			t.Fatalf("Resource not found")
   581  //		}
   582  //
   583  //		queryProvider := resource.(modconfig.QueryProvider)
   584  //		actualRuntimeDeps := queryProvider.GetRuntimeDependencies()
   585  //		// compare the lengths
   586  //		if len(actualRuntimeDeps) != len(expected) {
   587  //			t.Fatalf("Runtime dependencies not equal")
   588  //		}
   589  //
   590  //		// if actual is equal to expected
   591  //		for i, expectedDep := range expectedDeps {
   592  //			rd, notFound := actualRuntimeDeps[i]
   593  //			if !notFound {
   594  //				t.Fatalf("Runtime dependencies not equal")
   595  //			}
   596  //			if !expectedDep.Equals(rd) {
   597  //				t.Fatalf("Runtime dependencies not equal")
   598  //			}
   599  //		}
   600  //	}
   601  //	return true
   602  //}
   603  
   604  // old code (TBD to remove)
   605  // the actual mod loading logic is tested more thoroughly in TestLoadMod (steampipeconfig/load_mod_test.go)
   606  // this test is primarily to verify the QueryMap building
   607  // type loadWorkspaceTest struct {
   608  // 	source   string
   609  // 	expected interface{}
   610  // }
   611  
   612  // var toStringPointer = utils.ToStringPointer
   613  
   614  // var testCasesLoadWorkspace = map[string]loadWorkspaceTest{
   615  // 	"single mod": {
   616  // 		source: "test_data/w_1",
   617  // 		expected: &Workspace{
   618  // 			Mod: &modconfig.Mod{
   619  // 				ShortName: "w_1",
   620  // 				Title:     toStringPointer("workspace 1"),
   621  // 				//ModDepends: []*modconfig.ModVersionConstraint{
   622  // 				//	{ShortName: "github.com/turbot/m1", Version: "0.0.0"},
   623  // 				//	{ShortName: "github.com/turbot/m2", Version: "0.0.0"},
   624  // 				//},
   625  // 				Queries: map[string]*modconfig.Query{
   626  // 					"localq1": {
   627  // 						ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   628  // 					},
   629  // 					"localq2": {
   630  // 						ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   631  // 					},
   632  // 				},
   633  // 			},
   634  // 			//Queries: map[string]*modconfig.Query{
   635  // 			//	"w_1.query.localq1": {
   636  // 			//		ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   637  // 			//	},
   638  // 			//	"query.localq1": {
   639  // 			//		ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   640  // 			//	},
   641  // 			//	"w_2.query.localq2": {
   642  // 			//		ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   643  // 			//	},
   644  // 			//	"query.localq2": {
   645  // 			//		ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   646  // 			//	},
   647  // 			//	"m1.query.q1": {
   648  // 			//		ShortName: "q1", FullName: "Q1", Description: toStringPointer("THIS IS QUERY 1"), Documentation: toStringPointer("select 1"),
   649  // 			//	},
   650  // 			//	"m2.query.q2": {
   651  // 			//		ShortName: "q2", FullName: "Q2", Description: toStringPointer("THIS IS QUERY 2"), Documentation: toStringPointer("select 2"),
   652  // 			//	},
   653  // 			//},
   654  // 		},
   655  // 	},
   656  // 	"single_mod_with_ignored_directory": {
   657  // 		source: "test_data/single_mod_with_ignored_directory",
   658  // 		expected: &Workspace{Mod: &modconfig.Mod{
   659  // 			ShortName:   "m1",
   660  // 			Title:       toStringPointer("M1"),
   661  // 			Description: toStringPointer("THIS IS M1"),
   662  // 			Queries: map[string]*modconfig.Query{
   663  // 				"q1": {
   664  // 					ShortName: "q1", FullName: "Q1", Description: toStringPointer("THIS IS QUERY 1"), Documentation: toStringPointer("select 1"),
   665  // 				},
   666  // 				"q2": {
   667  // 					ShortName: "q2", FullName: "Q2", Description: toStringPointer("THIS IS QUERY 2"), Documentation: toStringPointer("select 2"),
   668  // 				},
   669  // 			},
   670  // 		},
   671  // 		},
   672  // 	},
   673  // 	"single_mod_with_ignored_sql_files": {
   674  // 		source: "test_data/single_mod_with_ignored_sql_files",
   675  // 		expected: &Workspace{Mod: &modconfig.Mod{
   676  // 			ShortName:   "m1",
   677  // 			Title:       toStringPointer("M1"),
   678  // 			Description: toStringPointer("THIS IS M1"),
   679  // 			Queries: map[string]*modconfig.Query{
   680  // 				"q1": {
   681  // 					ShortName: "q1", FullName: "Q1", Description: toStringPointer("THIS IS QUERY 1"), Documentation: toStringPointer("select 1"),
   682  // 				},
   683  // 			},
   684  // 		}},
   685  // 	},
   686  // 	"single_mod_in_hidden_folder": {
   687  // 		source: "test_data/.hidden/w_1",
   688  // 		expected: &Workspace{
   689  // 			Mod: &modconfig.Mod{
   690  // 				ShortName: "w_1",
   691  // 				Title:     toStringPointer("workspace 1"),
   692  // 				Queries: map[string]*modconfig.Query{
   693  // 					"localq1": {
   694  // 						ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   695  // 					},
   696  // 					"localq2": {
   697  // 						ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   698  // 					},
   699  // 				},
   700  // 			},
   701  // 			//Queries: map[string]*modconfig.Query{
   702  // 			//	"w_1.query.localq1": {
   703  // 			//		ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   704  // 			//	},
   705  // 			//	"query.localq1": {
   706  // 			//		ShortName: "localq1", Title: toStringPointer("LocalQ1"), Description: toStringPointer("THIS IS LOCAL QUERY 1"), SQL: toStringPointer(".tables"),
   707  // 			//	},
   708  // 			//	"w_2.query.localq2": {
   709  // 			//		ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   710  // 			//	},
   711  // 			//	"query.localq2": {
   712  // 			//		ShortName: "localq2", Title: toStringPointer("LocalQ2"), Description: toStringPointer("THIS IS LOCAL QUERY 2"), SQL: toStringPointer(".inspect"),
   713  // 			//	},
   714  // 			//	"m1.query.q1": {
   715  // 			//		ShortName: "q1", FullName: "Q1", Description: toStringPointer("THIS IS QUERY 1"), Documentation: toStringPointer("select 1"),
   716  // 			//	},
   717  // 			//	"m2.query.q2": {
   718  // 			//		ShortName: "q2", FullName: "Q2", Description: toStringPointer("THIS IS QUERY 2"), Documentation: toStringPointer("select 2"),
   719  // 			//	},
   720  // 			//},
   721  // 		},
   722  // 	},
   723  // }
   724  
   725  // func TestLoadWorkspace(t *testing.T) {
   726  // 	for name, test := range testCasesLoadWorkspace {
   727  // 		workspacePath, err := filepath.Abs(test.source)
   728  // 		workspace, err := Load(context.Background(), workspacePath)
   729  
   730  // 		if err != nil {
   731  // 			if test.expected != "ERROR" {
   732  // 				t.Errorf("Test: '%s'' FAILED with unexpected error: %v", name, err)
   733  // 			}
   734  // 			continue
   735  // 		}
   736  
   737  // 		if test.expected == "ERROR" {
   738  // 			t.Errorf("Test: '%s'' FAILED - expected error", name)
   739  // 			continue
   740  // 		}
   741  
   742  // 		if match, message := WorkspacesEqual(test.expected.(*Workspace), workspace); !match {
   743  // 			t.Errorf("Test: '%s'' FAILED : %s", name, message)
   744  // 		}
   745  // 	}
   746  // }
   747  
   748  // func WorkspacesEqual(expected, actual *Workspace) (bool, string) {
   749  
   750  // 	errors := []string{}
   751  // 	if actual.Mod.String() != expected.Mod.String() {
   752  // 		errors = append(errors, fmt.Sprintf("workspace mods do not match - expected \n\n%s\n\nbut got\n\n%s\n", expected.Mod.String(), actual.Mod.String()))
   753  // 	}
   754  // 	expectedMaps := expected.GetResourceMaps()
   755  // 	actualMaps := actual.GetResourceMaps()
   756  
   757  // 	for name, expectedQuery := range expectedMaps.Queries {
   758  // 		actualQuery, ok := actualMaps.Queries[name]
   759  // 		if ok {
   760  // 			if expectedQuery.String() != actualQuery.String() {
   761  // 				errors = append(errors, fmt.Sprintf("query %s expected\n\n%s\n\n, got\na\n%s\n\n", name, expectedQuery.String(), actualQuery.String()))
   762  // 			}
   763  // 		} else {
   764  // 			errors = append(errors, fmt.Sprintf("mod map missing expected key %s", name))
   765  // 		}
   766  // 	}
   767  // 	for name := range actualMaps.Queries {
   768  // 		if _, ok := expectedMaps.Queries[name]; ok {
   769  // 			errors = append(errors, fmt.Sprintf("unexpected query %s in query map", name))
   770  // 		}
   771  // 	}
   772  // 	return len(errors) > 0, strings.Join(errors, "\n")
   773  // }