Skip to content

Commit

Permalink
chore: fix tests (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
coadler authored Jul 12, 2024
1 parent 8c23074 commit 746acae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions internal/provider/example_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package provider
import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -23,7 +22,7 @@ func NewExampleDataSource() datasource.DataSource {

// ExampleDataSource defines the data source implementation.
type ExampleDataSource struct {
client *http.Client
data *CoderdProviderData
}

// ExampleDataSourceModel describes the data source data model.
Expand Down Expand Up @@ -60,18 +59,18 @@ func (d *ExampleDataSource) Configure(ctx context.Context, req datasource.Config
return
}

client, ok := req.ProviderData.(*http.Client)
client, ok := req.ProviderData.(*CoderdProviderData)

if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *http.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *CoderdProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
}

d.client = client
d.data = client
}

func (d *ExampleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/example_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func TestAccExampleDataSource(t *testing.T) {
}

const testAccExampleDataSourceConfig = `
provider coderd {
url = "https://dev.coder.com"
token = "iamnotarealtoken"
}
data "coderd_example" "test" {
configurable_attribute = "example"
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/user_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *UserResource) Configure(ctx context.Context, req resource.ConfigureRequ
if !ok {
resp.Diagnostics.AddError(
"Unexpected Resource Configure Type",
fmt.Sprintf("Expected *codersdk.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData),
fmt.Sprintf("Expected *CoderdProviderData, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)

return
Expand Down

0 comments on commit 746acae

Please sign in to comment.