diff --git a/pipelines/data_pipelines_test.go b/pipelines/data_pipelines_test.go index a1693492fd..b08b2fb2a2 100755 --- a/pipelines/data_pipelines_test.go +++ b/pipelines/data_pipelines_test.go @@ -1,129 +1,127 @@ -// package pipelines - -// import ( -// "testing" +package pipelines -// "github.com/databricks/terraform-provider-databricks/qa" -// ) +import ( + "testing" -// func TestDataSourcePipeline_Error(t *testing.T) { -// qa.ResourceFixture{ -// Fixtures: qa.HTTPFailures, -// Resource: DataSourcePipelines(), -// Read: true, -// NonWritable: true, -// ID: "_", -// }.ExpectError(t, "i'm a teapot") -// } + "github.com/databricks/terraform-provider-databricks/qa" +) -// func TestDataSourcePipelines(t *testing.T) { -// qa.ResourceFixture{ -// Fixtures: []qa.HTTPFixture{ -// { -// Method: "GET", -// Resource: "/api/2.0/pipelines?max_results=100", -// Response: PipelineListResponse{ -// Statuses: []PipelineStateInfo{ -// { -// PipelineID: "123", -// Name: "Pipeline1", -// CreatorUserName: "user1", -// }, -// }, -// }, -// }, -// { -// Method: "GET", -// Resource: "/api/2.0/pipelines?max_results=100&page_token=token1", -// Response: PipelineListResponse{ -// Statuses: []PipelineStateInfo{ -// { -// PipelineID: "123", -// Name: "Pipeline1", -// CreatorUserName: "user1", -// }, -// }, -// NextPageToken: "token1", -// }, -// }, -// }, -// Resource: DataSourcePipelines(), -// Read: true, -// NonWritable: true, -// ID: "_", -// }.ApplyAndExpectData(t, map[string]any{ -// "ids": []string{ -// "123", -// }, -// }) -// } +func TestDataSourcePipeline_Error(t *testing.T) { + qa.ResourceFixture{ + Fixtures: qa.HTTPFailures, + Resource: DataSourcePipelines(), + Read: true, + NonWritable: true, + ID: "_", + }.ExpectError(t, "i'm a teapot") +} -// func TestDataSourcePipelines_Search(t *testing.T) { -// qa.ResourceFixture{ -// Fixtures: []qa.HTTPFixture{ -// { -// Method: "GET", -// Resource: "/api/2.0/pipelines?filter=name+LIKE+%27Pipeline1%27&max_results=100", -// Response: PipelineListResponse{ -// Statuses: []PipelineStateInfo{ -// { -// PipelineID: "123", -// Name: "Pipeline1", -// CreatorUserName: "user1", -// }, -// }, -// }, -// }, -// }, -// Resource: DataSourcePipelines(), -// HCL: `pipeline_name = "Pipeline1"`, -// Read: true, -// NonWritable: true, -// //Create: true, -// ID: "_", -// }.ApplyAndExpectData(t, map[string]any{ -// "ids": []string{ -// "123", -// }, -// }) -// } +func TestDataSourcePipelines(t *testing.T) { + qa.ResourceFixture{ + Fixtures: []qa.HTTPFixture{ + { + Method: "GET", + Resource: "/api/2.0/pipelines?max_results=100", + Response: PipelineListResponse{ + Statuses: []PipelineStateInfo{ + { + PipelineID: "123", + Name: "Pipeline1", + CreatorUserName: "user1", + }, + }, + }, + }, + { + Method: "GET", + Resource: "/api/2.0/pipelines?max_results=100&page_token=token1", + Response: PipelineListResponse{ + Statuses: []PipelineStateInfo{ + { + PipelineID: "123", + Name: "Pipeline1", + CreatorUserName: "user1", + }, + }, + NextPageToken: "token1", + }, + }, + }, + Resource: DataSourcePipelines(), + Read: true, + NonWritable: true, + ID: "_", + }.ApplyAndExpectData(t, map[string]any{ + "ids": []string{ + "123", + }, + }) +} -// func TestDataSourcePipelines_SearchError(t *testing.T) { -// //_, err := qa.ResourceFixture{ -// qa.ResourceFixture{ -// Fixtures: []qa.HTTPFixture{ -// { -// Method: "GET", -// Resource: "/api/2.0/pipelines?filter=name+LIKE+%27Pipeline2%27&max_results=100", -// Response: PipelineListResponse{}, -// }, -// }, -// Resource: DataSourcePipelines(), -// HCL: `pipeline_name = "Pipeline2"`, -// Read: true, -// NonWritable: true, -// //Create: true, -// ID: "_", -// }.ApplyNoError(t) -// } +func TestDataSourcePipelines_Search(t *testing.T) { + qa.ResourceFixture{ + Fixtures: []qa.HTTPFixture{ + { + Method: "GET", + Resource: "/api/2.0/pipelines?filter=name+LIKE+%27Pipeline1%27&max_results=100", + Response: PipelineListResponse{ + Statuses: []PipelineStateInfo{ + { + PipelineID: "123", + Name: "Pipeline1", + CreatorUserName: "user1", + }, + }, + }, + }, + }, + Resource: DataSourcePipelines(), + HCL: `pipeline_name = "Pipeline1"`, + Read: true, + NonWritable: true, + //Create: true, + ID: "_", + }.ApplyAndExpectData(t, map[string]any{ + "ids": []string{ + "123", + }, + }) +} -// func TestDataSourcePipelines_NoneFound(t *testing.T) { -// //_, err := qa.ResourceFixture{ -// qa.ResourceFixture{ -// Fixtures: []qa.HTTPFixture{ -// { -// Method: "GET", -// Resource: "/api/2.0/pipelines?max_results=100", -// Response: PipelineListResponse{}, -// }, -// }, -// Resource: DataSourcePipelines(), -// HCL: `pipeline_name = ""`, -// Read: true, -// NonWritable: true, -// //Create: true, -// ID: "_", -// }.ApplyNoError(t) -// } +func TestDataSourcePipelines_SearchError(t *testing.T) { + //_, err := qa.ResourceFixture{ + qa.ResourceFixture{ + Fixtures: []qa.HTTPFixture{ + { + Method: "GET", + Resource: "/api/2.0/pipelines?filter=name+LIKE+%27Pipeline2%27&max_results=100", + Response: PipelineListResponse{}, + }, + }, + Resource: DataSourcePipelines(), + HCL: `pipeline_name = "Pipeline2"`, + Read: true, + NonWritable: true, + //Create: true, + ID: "_", + }.ApplyNoError(t) +} -package pipelines +func TestDataSourcePipelines_NoneFound(t *testing.T) { + //_, err := qa.ResourceFixture{ + qa.ResourceFixture{ + Fixtures: []qa.HTTPFixture{ + { + Method: "GET", + Resource: "/api/2.0/pipelines?max_results=100", + Response: PipelineListResponse{}, + }, + }, + Resource: DataSourcePipelines(), + HCL: `pipeline_name = ""`, + Read: true, + NonWritable: true, + //Create: true, + ID: "_", + }.ApplyNoError(t) +} diff --git a/provider/provider.go b/provider/provider.go index 00f5fd0f7c..32eee067c5 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -32,7 +32,6 @@ import ( "github.com/databricks/terraform-provider-databricks/mws" "github.com/databricks/terraform-provider-databricks/permissions" "github.com/databricks/terraform-provider-databricks/pipelines" - "github.com/databricks/terraform-provider-databricks/policies" "github.com/databricks/terraform-provider-databricks/pools" "github.com/databricks/terraform-provider-databricks/repos"