Skip to content

Commit

Permalink
azurerm_orbital_contact_profile: fix creation without event_hub_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyeqf committed Mar 4, 2024
1 parent ecd7208 commit 196dc3a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/services/orbital/contact_profile_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ func (r ContactProfileResource) Create() sdk.ResourceFunc {
SubnetId: model.NetworkConfigurationSubnetId,
}

// The service only accept `null` or non-empty value, empty string will cause a 400 response
var eventHubUri *string
if model.EventHubUri != "" {
eventHubUri = pointer.To(model.EventHubUri)
}

contactProfilesProperties := contactprofile.ContactProfilesProperties{
AutoTrackingConfiguration: pointer.To(autoTrackingConfiguration),
EventHubUri: pointer.To(model.EventHubUri),
EventHubUri: eventHubUri,
Links: links,
MinimumElevationDegrees: pointer.To(model.MinimumElevationDegrees),
MinimumViableContactDuration: pointer.To(model.MinimumVariableContactDuration),
Expand Down
22 changes: 22 additions & 0 deletions internal/services/orbital/contact_profile_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ func TestAccContactProfile_multipleChannels(t *testing.T) {
})
}

func TestAccContactProfile_addChannel(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_orbital_contact_profile", "test")
r := ContactProfileResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.multipleChannels(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccContactProfile_update(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_orbital_contact_profile", "test")
r := ContactProfileResource{}
Expand Down
1 change: 0 additions & 1 deletion internal/services/orbital/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func ChannelSchema() *pluginsdk.Schema {
return &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Required: true,
ForceNew: true,
MinItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*schema.Schema{
Expand Down

0 comments on commit 196dc3a

Please sign in to comment.