Skip to content

Commit

Permalink
#2161 fix edge model update (#2170)
Browse files Browse the repository at this point in the history
* Hide certificates when getting the magic ommand

* fix edge model update

* fix failed test

---------

Co-authored-by: Kevin BEAUGRAND <contact@kbeaugrand.fr>
  • Loading branch information
ssgueye2 and kbeaugrand committed Jun 18, 2023
1 parent 2f31886 commit ffd4feb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<ChildContent>
<MudGrid>
<MudItem xs="12" md="6">
<MudTextField id="@nameof(EdgeModel.Name)" @bind-Value="@EdgeModel.Name" For="@(() => EdgeModel.Name)" Label="Name" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" />
<MudTextField id="@nameof(EdgeModel.Name)" @bind-Value="@EdgeModel.Name" For="@(() => EdgeModel.Name)" Label="Name" Margin="Margin.Dense" Variant="Variant.Outlined" Required="true" ReadOnly="true"/>
</MudItem>
<MudItem xs="12" md="6">
<MudTextField id="@nameof(EdgeModel.Description)" @bind-Value="@EdgeModel.Description" For="@(() => EdgeModel.Description)" Label="Description" Variant="Variant.Outlined" Lines="5" />
Expand Down
19 changes: 10 additions & 9 deletions src/AzureIoTHub.Portal.Infrastructure/Services/EdgeModelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,21 @@ public async Task UpdateEdgeModel(IoTEdgeModel edgeModel)
foreach (var labelEntity in edgeModelEntity.Labels)
{
this.labelRepository.Delete(labelEntity.Id);
}

}

edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel);

_ = this.mapper.Map(edgeModel, edgeModelEntity);

this.edgeModelRepository.Update(edgeModelEntity);


// For AWS, we do the update in the AwsConfiguration
if (this.config.CloudProvider.Equals(CloudProviders.Azure, StringComparison.Ordinal))
{
_ = this.mapper.Map(edgeModel, edgeModelEntity);

this.edgeModelRepository.Update(edgeModelEntity);

await SaveModuleCommands(edgeModel);
await SaveModuleCommands(edgeModel);

}

edgeModel.ExternalIdentifier = await this.configService.RollOutEdgeModelConfiguration(edgeModel);

await this.unitOfWork.SaveAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ public async Task UpdateEdgeModelForAWSShouldUpdateEdgeModel()
this.mockLabelRepository.Setup(repository => repository.Delete(It.IsAny<string>()))
.Verifiable();

_ = this.mockEdgeDeviceModelRepository.Setup(repository => repository.Update(It.IsAny<EdgeDeviceModel>()));
_ = this.mockUnitOfWork.Setup(work => work.SaveAsync())
.Returns(Task.CompletedTask);

_ = this.mockConfigService.Setup(x => x.RollOutEdgeModelConfiguration(It.IsAny<IoTEdgeModel>()))
.Returns(Task.FromResult(Fixture.Create<string>()));

Expand Down

0 comments on commit ffd4feb

Please sign in to comment.