Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-aleksandrboldyrev committed Nov 5, 2024
1 parent 089bed8 commit 1d6b333
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
func setupMockClientLocalProcessingAgentDataSourceConfigMapping(t *testing.T) {
tfmock.MockClient().Reset()

lpaDataSourceMockGetHandler = tfmock.MockClient().When(http.MethodGet, "/v1/local-processing-agents/lpa_id").ThenCall(
lpaDataSourceMockGetHandler = tfmock.MockClient().When(http.MethodGet, "/v1/hybrid-deployment-agents/lpa_id").ThenCall(
func(req *http.Request) (*http.Response, error) {
lpaDataSourceMockData = tfmock.CreateMapFromJsonString(t, lpaMappingResponse)
return tfmock.FivetranSuccessResponse(t, req, http.StatusOK, "Success", lpaDataSourceMockData), nil
Expand All @@ -66,12 +66,6 @@ func TestDataSourceLocalProcessingAgentMappingMock(t *testing.T) {
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "display_name", "display_name"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "group_id", "group_id"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "registered_at", "registered_at"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.connection_id", "connection_id1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.schema", "schema1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.0.service", "service1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.connection_id", "connection_id2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.schema", "schema2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agent.test_lpa", "usage.1.service", "service2"),*/
),
}

Expand Down
15 changes: 1 addition & 14 deletions fivetran/framework/datasources/local_processing_agents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const (
func setupMockClientLocalProcessingAgentsDataSourceConfigMapping(t *testing.T) {
tfmock.MockClient().Reset()

localProcessingAgentsDataSourceMockGetHandler = tfmock.MockClient().When(http.MethodGet, "/v1/local-processing-agents").ThenCall(
localProcessingAgentsDataSourceMockGetHandler = tfmock.MockClient().When(http.MethodGet, "/v1/hybrid-deployment-agents").ThenCall(
func(req *http.Request) (*http.Response, error) {
localProcessingAgentsDataSourceMockData = tfmock.CreateMapFromJsonString(t, localProcessingAgentsMappingResponse)
return tfmock.FivetranSuccessResponse(t, req, http.StatusOK, "Success", localProcessingAgentsDataSourceMockData), nil
Expand All @@ -87,22 +87,9 @@ func TestDataSourceLocalProcessingAgentsMappingMock(t *testing.T) {
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.display_name", "display_name1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.group_id", "group_id1"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.registered_at", "registered_at1"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.connection_id", "connection_id11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.schema", "schema11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.0.service", "service11"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.connection_id", "connection_id12"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.schema", "schema12"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.0.usage.1.service", "service12"),*/

resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.display_name", "display_name2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.group_id", "group_id2"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.registered_at", "registered_at2"),
/*resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.connection_id", "connection_id21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.schema", "schema21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.0.service", "service21"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.connection_id", "connection_id22"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.schema", "schema22"),
resource.TestCheckResourceAttr("data.fivetran_local_processing_agents.test_lpa", "items.1.usage.1.service", "service22"),*/
),
}

Expand Down
4 changes: 2 additions & 2 deletions fivetran/framework/resources/local_processing_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func setupMockClientLocalProcessingAgentResource(t *testing.T) {
}
}`

localProcessingAgentPostHandler = tfmock.MockClient().When(http.MethodPost, "/v1/local-processing-agents").ThenCall(
localProcessingAgentPostHandler = tfmock.MockClient().When(http.MethodPost, "/v1/hybrid-deployment-agents").ThenCall(
func(req *http.Request) (*http.Response, error) {
localProcessingAgentData = tfmock.CreateMapFromJsonString(t, localProcessingAgentResponse)
return tfmock.FivetranSuccessResponse(t, req, http.StatusCreated, "Local Processing Agent has been created", localProcessingAgentData), nil
Expand All @@ -44,7 +44,7 @@ func setupMockClientLocalProcessingAgentResource(t *testing.T) {
},
)

localProcessingAgentDeleteHandler = tfmock.MockClient().When(http.MethodDelete, "/v1/local-processing-agents/lpa_id").ThenCall(
localProcessingAgentDeleteHandler = tfmock.MockClient().When(http.MethodDelete, "/v1/hybrid-deployment-agents/lpa_id").ThenCall(
func(req *http.Request) (*http.Response, error) {
return tfmock.FivetranSuccessResponse(t, req, 200, "Local Processing Agent has been deleted", nil), nil
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func testFivetranLocalProcessingAgentResourceCreate(t *testing.T, resourceName s
return func(s *terraform.State) error {
rs := GetResource(t, s, resourceName)

_, err := client.NewLocalProcessingAgentDetails().AgentId(rs.Primary.ID).Do(context.Background())
_, err := client.NewHybridDeploymentAgentDetails().AgentId(rs.Primary.ID).Do(context.Background())
if err != nil {
fmt.Println(err)
return err
Expand All @@ -59,7 +59,7 @@ func testFivetranLocalProcessingAgentResourceDestroy(s *terraform.State) error {
continue
}

response, err := client.NewLocalProcessingAgentDetails().AgentId(rs.Primary.ID).Do(context.Background())
response, err := client.NewHybridDeploymentAgentDetails().AgentId(rs.Primary.ID).Do(context.Background())
if err.Error() != "status code: 404; expected: 200" {
return err
}
Expand Down

0 comments on commit 1d6b333

Please sign in to comment.