Skip to content

Commit

Permalink
Merge pull request #4 from Macro-Deck-App/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
manuelmayer-dev authored Jun 7, 2023
2 parents dd7c957 + 9973b43 commit 1b4a59c
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 7 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ The `ApiV2VersionInfo` class provides information about a Macro Deck version. Th

- **Properties**:
- `Version`: A string representation of the Macro Deck version.
- `Platforms`: A dictionary mapping `PlatformIdentifier` enum values to their respective download links for the specified version.
- `Platforms`: A dictionary mapping `PlatformIdentifier` enum values to their respective `ApiV2VersionFileInfo` objects for the specified version.

### `ApiV2VersionFileInfo`

The `ApiV2VersionFileInfo` class provides information about a specific version file of Macro Deck. This includes the download URL, file hash, and file size.

- **Properties**:
- `DownloadUrl`: A string representing the download URL for the version file.
- `FileHash`: A string representing the hash of the version file.
- `FileSize`: A long integer representing the file size of the version file.

### `ApiV2CheckResult`

The `ApiV2CheckResult` class provides the result of a version check for Macro Deck. It includes a boolean indicating if a newer version is available and an `ApiV2VersionInfo` object providing details about the available version, if applicable.

- **Properties**:
- `NewerVersionAvailable`: A boolean indicating whether a newer version of Macro Deck is available.
- `Version`: An instance of `ApiV2VersionInfo` providing information about the newer version if one is available; null otherwise.
- `Version`: An instance of `ApiV2VersionInfo` providing information about the newer version if one is available
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MacroDeck.UpdateService.Core.DataTypes.ApiV2;

public class ApiV2VersionFileInfo
{
public string DownloadUrl { get; set; } = string.Empty;
public string FileHash { get; set; } = string.Empty;
public long FileSize { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace MacroDeck.UpdateService.Core.DataTypes.ApiV2;
public class ApiV2VersionInfo
{
public string Version { get; set; } = string.Empty;
public Dictionary<PlatformIdentifier, string> Platforms { get; set; } = new();
public Dictionary<PlatformIdentifier, ApiV2VersionFileInfo> Platforms { get; set; } = new();
}
8 changes: 8 additions & 0 deletions src/MacroDeck.UpdateService.Core/DataTypes/VersionFileInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace MacroDeck.UpdateService.Core.DataTypes;

public class VersionFileInfo
{
public string DownloadUrl { get; set; } = string.Empty;
public string FileHash { get; set; } = string.Empty;
public long FileSize { get; set; }
}
2 changes: 1 addition & 1 deletion src/MacroDeck.UpdateService.Core/DataTypes/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace MacroDeck.UpdateService.Core.DataTypes;
public class VersionInfo
{
public string Version { get; set; } = string.Empty;
public Dictionary<PlatformIdentifier, string> Platforms { get; set; } = new();
public Dictionary<PlatformIdentifier, VersionFileInfo> Platforms { get; set; } = new();
}
1 change: 1 addition & 0 deletions src/MacroDeck.UpdateService/AutoMapper/ApiV2Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public ApiV2Profile()
{
CreateMap<VersionInfo, ApiV2VersionInfo>();
CreateMap<CheckResult, ApiV2CheckResult>();
CreateMap<VersionFileInfo, ApiV2VersionFileInfo>();
}
}
7 changes: 6 additions & 1 deletion src/MacroDeck.UpdateService/AutoMapper/VersionProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public VersionProfile()
Version = src.Version,
Platforms = src.Files.ToDictionary(
f => f.PlatformIdentifier,
f => FileProviderUrlBuilder.GetUrl(f.FileProvider, src.Version, f.FileName))
f => new VersionFileInfo
{
DownloadUrl = FileProviderUrlBuilder.GetUrl(f.FileProvider, src.Version, f.FileName),
FileHash = f.FileHash,
FileSize = f.FileSize
})
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public async Task ApiV2Controller_GetVersion_Returns_Correct_Version()
var version1 = await _versionDatabaseSeeder.CreateVersion(entity => entity.Version = "1.0.0");
var version2 = await _versionDatabaseSeeder.CreateVersion(entity => entity.Version = "1.1.0");

await _versionFileDatabaseSeeder.CreateVersionFile(version1, update: entity =>
var versionFile = await _versionFileDatabaseSeeder.CreateVersionFile(version1, update: entity =>
{
entity.FileProvider = FileProvider.GitHub;
entity.PlatformIdentifier = platform;
Expand All @@ -327,8 +327,10 @@ await _versionFileDatabaseSeeder.CreateVersionFile(version1, update: entity =>

Assert.That(result1.Version, Is.EqualTo(version1.Version));
Assert.That(result1.Platforms, Contains.Key(platform));
Assert.That(result1.Platforms[platform],
Assert.That(result1.Platforms[platform].DownloadUrl,
Is.EqualTo(FileProviderUrlBuilder.GetUrl(FileProvider.GitHub, version1.Version, fileName)));
Assert.That(result1.Platforms[platform].FileSize, Is.EqualTo(versionFile.FileSize));
Assert.That(result1.Platforms[platform].FileHash, Is.EqualTo(versionFile.FileHash));

var result2 = await IntegrationTestHelper.TestClientRequest
.AppendPathSegment(IntegrationTestConstants.ApiV2VersionBase)
Expand Down

0 comments on commit 1b4a59c

Please sign in to comment.