Skip to content

Commit

Permalink
Merge pull request #4838 from cloudflare/acc-tests-for-bindings
Browse files Browse the repository at this point in the history
test(workers_script): add coverage for bindings
  • Loading branch information
jacobbednarz authored Jan 7, 2025
2 parents 80dd286 + cb22092 commit c57923a
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 411 deletions.
58 changes: 31 additions & 27 deletions internal/services/workers_script/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/cloudflare/terraform-provider-cloudflare/internal/apijson"
"github.com/cloudflare/terraform-provider-cloudflare/internal/customfield"
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/jinzhu/copier"
)
Expand All @@ -18,17 +17,17 @@ type WorkersScriptResultEnvelope struct {
}

type WorkersScriptModel struct {
ID types.String `tfsdk:"id" json:"-,computed"`
ScriptName types.String `tfsdk:"script_name" path:"script_name,required"`
AccountID types.String `tfsdk:"account_id" path:"account_id,required"`
Message types.String `tfsdk:"message" json:"message,optional"`
Content types.String `tfsdk:"content" json:"content,required"`
CreatedOn timetypes.RFC3339 `tfsdk:"created_on" json:"created_on,computed" format:"date-time"`
Etag types.String `tfsdk:"etag" json:"etag,computed"`
HasAssets types.Bool `tfsdk:"has_assets" json:"has_assets,computed"`
HasModules types.Bool `tfsdk:"has_modules" json:"has_modules,computed"`
ModifiedOn timetypes.RFC3339 `tfsdk:"modified_on" json:"modified_on,computed" format:"date-time"`
StartupTimeMs types.Int64 `tfsdk:"startup_time_ms" json:"startup_time_ms,computed"`
ID types.String `tfsdk:"id" json:"-,computed"`
ScriptName types.String `tfsdk:"script_name" path:"script_name,required"`
AccountID types.String `tfsdk:"account_id" path:"account_id,required"`
// Message types.String `tfsdk:"message" json:"message,optional"`
Content types.String `tfsdk:"content" json:"content,required"`
// CreatedOn timetypes.RFC3339 `tfsdk:"created_on" json:"created_on,computed" format:"date-time"`
// Etag types.String `tfsdk:"etag" json:"etag,computed"`
// HasAssets types.Bool `tfsdk:"has_assets" json:"has_assets,computed"`
// HasModules types.Bool `tfsdk:"has_modules" json:"has_modules,computed"`
// ModifiedOn timetypes.RFC3339 `tfsdk:"modified_on" json:"modified_on,computed" format:"date-time"`
// StartupTimeMs types.Int64 `tfsdk:"startup_time_ms" json:"startup_time_ms,computed"`

WorkersScriptMetadataModel
}
Expand Down Expand Up @@ -63,21 +62,21 @@ func (r WorkersScriptModel) MarshalMultipart() (data []byte, contentType string,
}

type WorkersScriptMetadataModel struct {
Assets customfield.NestedObject[WorkersScriptMetadataAssetsModel] `tfsdk:"assets" json:"assets,computed_optional"`
Bindings customfield.NestedObjectList[WorkersScriptMetadataBindingsModel] `tfsdk:"bindings" json:"bindings,computed_optional"`
BodyPart types.String `tfsdk:"body_part" json:"body_part,optional"`
CompatibilityDate types.String `tfsdk:"compatibility_date" json:"compatibility_date,optional"`
CompatibilityFlags *[]types.String `tfsdk:"compatibility_flags" json:"compatibility_flags,optional"`
KeepAssets types.Bool `tfsdk:"keep_assets" json:"keep_assets,optional"`
KeepBindings *[]types.String `tfsdk:"keep_bindings" json:"keep_bindings,optional"`
Logpush types.Bool `tfsdk:"logpush" json:"logpush,optional"`
MainModule types.String `tfsdk:"main_module" json:"main_module,optional"`
Migrations customfield.NestedObject[WorkersScriptMetadataMigrationsModel] `tfsdk:"migrations" json:"migrations,computed_optional"`
Observability customfield.NestedObject[WorkersScriptMetadataObservabilityModel] `tfsdk:"observability" json:"observability,computed_optional"`
Placement customfield.NestedObject[WorkersScriptMetadataPlacementModel] `tfsdk:"placement" json:"placement,computed_optional"`
Tags *[]types.String `tfsdk:"tags" json:"tags,optional"`
TailConsumers customfield.NestedObjectList[WorkersScriptMetadataTailConsumersModel] `tfsdk:"tail_consumers" json:"tail_consumers,computed_optional"`
UsageModel types.String `tfsdk:"usage_model" json:"usage_model,optional"`
Assets customfield.NestedObject[WorkersScriptMetadataAssetsModel] `tfsdk:"assets" json:"assets,computed_optional"`
Bindings customfield.NestedObjectList[WorkersScriptMetadataBindingsModel] `tfsdk:"bindings" json:"bindings,computed_optional"`
BodyPart types.String `tfsdk:"body_part" json:"body_part,optional"`
CompatibilityDate types.String `tfsdk:"compatibility_date" json:"compatibility_date,optional"`
CompatibilityFlags *[]types.String `tfsdk:"compatibility_flags" json:"compatibility_flags,optional"`
KeepAssets types.Bool `tfsdk:"keep_assets" json:"keep_assets,optional"`
KeepBindings *[]types.String `tfsdk:"keep_bindings" json:"keep_bindings,optional"`
Logpush types.Bool `tfsdk:"logpush" json:"logpush,optional"`
MainModule types.String `tfsdk:"main_module" json:"main_module,optional"`
Migrations customfield.NestedObject[WorkersScriptMetadataMigrationsModel] `tfsdk:"migrations" json:"migrations,computed_optional"`
Observability customfield.NestedObject[WorkersScriptMetadataObservabilityModel] `tfsdk:"observability" json:"observability,computed_optional"`
Placement customfield.NestedObject[WorkersScriptMetadataPlacementModel] `tfsdk:"placement" json:"placement,computed_optional"`
// Tags *[]types.String `tfsdk:"tags" json:"tags,optional"`
TailConsumers customfield.NestedObjectList[WorkersScriptMetadataTailConsumersModel] `tfsdk:"tail_consumers" json:"tail_consumers,computed_optional"`
UsageModel types.String `tfsdk:"usage_model" json:"usage_model,optional"`
}

type WorkersScriptMetadataAssetsModel struct {
Expand Down Expand Up @@ -162,6 +161,11 @@ type WorkersScriptMetadataMigrationsStepsTransferredClassesModel struct {
To types.String `tfsdk:"to" json:"to,optional"`
}

type WorkersScriptMetadataObservabilityModel struct {
Enabled types.Bool `tfsdk:"enabled" json:"enabled,required"`
HeadSamplingRate types.Float64 `tfsdk:"head_sampling_rate" json:"head_sampling_rate,optional"`
}

type WorkersScriptMetadataPlacementModel struct {
Mode types.String `tfsdk:"mode" json:"mode,optional"`
Status types.String `tfsdk:"status" json:"status,computed"`
Expand Down
Loading

0 comments on commit c57923a

Please sign in to comment.