Skip to content

Commit

Permalink
Change FeedType enum to VersionFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
zentron committed Dec 11, 2017
1 parent f719d81 commit 4484e73
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 144 deletions.
17 changes: 9 additions & 8 deletions source/Octopus.Server.Core.Versioning.Tests/Parsers/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NUnit.Framework;
using Octopus.Core.Resources;
using Octopus.Core.Resources.Metadata;
using Octopus.Core.Resources.Versioning;

namespace Octopus.Server.Core.Versioning.Tests.Parsers
{
Expand All @@ -23,15 +24,15 @@ public void ParseMavenPackageId()
{
var metadata = MavenParser.GetMetadataFromPackageID("Maven#com.google.guava#guava");
Assert.AreEqual(metadata.PackageId, "Maven#com.google.guava#guava");
Assert.AreEqual(metadata.FeedType, FeedType.Maven);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Maven);
}

[Test]
public void ParseNuGetPackageId()
{
var metadata = NuGetParser.GetMetadataFromPackageID("NuGet.Package");
Assert.AreEqual(metadata.PackageId, "NuGet.Package");
Assert.AreEqual(metadata.FeedType, FeedType.NuGet);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Semver);
}

[Test]
Expand All @@ -46,7 +47,7 @@ public void ParseMavenServerPackagePhysicalMetadata()
Assert.AreEqual(metadata.FileExtension, ".jar");
Assert.AreEqual(metadata.PackageId, "Maven#com.google.guava#guava");
Assert.AreEqual(metadata.Version, "23.3-jre");
Assert.AreEqual(metadata.FeedType, FeedType.Maven);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Maven);
Assert.AreEqual(metadata.Size, 123);
Assert.AreEqual(metadata.Hash, "hash");
}
Expand Down Expand Up @@ -78,7 +79,7 @@ public void ParseNuGetServerPackagePhysicalMetadata()
Assert.AreEqual(metadata.FileExtension, ".zip");
Assert.AreEqual(metadata.PackageId, "package.suffix");
Assert.AreEqual(metadata.Version, "1.0.0");
Assert.AreEqual(metadata.FeedType, FeedType.NuGet);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Semver);
Assert.AreEqual(metadata.Size, 123);
Assert.AreEqual(metadata.Hash, "hash");
}
Expand All @@ -91,7 +92,7 @@ public void ParseMavenServerPackage()
Assert.AreEqual(metadata.FileExtension, ".jar");
Assert.AreEqual(metadata.PackageId, "Maven#com.google.guava#guava");
Assert.AreEqual(metadata.Version, "23.3-jre");
Assert.AreEqual(metadata.FeedType, FeedType.Maven);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Maven);
}

[Test]
Expand All @@ -102,7 +103,7 @@ public void ParseMavenTargetPackage()
Assert.AreEqual(metadata.FileExtension, ".jar");
Assert.AreEqual(metadata.PackageId, "Maven#com.google.guava#guava");
Assert.AreEqual(metadata.Version, "22.0");
Assert.AreEqual(metadata.FeedType, FeedType.Maven);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Maven);
}

[Test]
Expand All @@ -123,7 +124,7 @@ public void ParseNugetServerPackage()
Assert.AreEqual(metadata.FileExtension, ".zip");
Assert.AreEqual(metadata.PackageId, "package.suffix");
Assert.AreEqual(metadata.Version, "1.0.0");
Assert.AreEqual(metadata.FeedType, FeedType.NuGet);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Semver);
}

[Test]
Expand All @@ -134,7 +135,7 @@ public void ParseNugetTargetPackage()
Assert.AreEqual(metadata.FileExtension, ".zip");
Assert.AreEqual(metadata.PackageId, "package.suffix");
Assert.AreEqual(metadata.Version, "1.0.0");
Assert.AreEqual(metadata.FeedType, FeedType.NuGet);
Assert.AreEqual(metadata.VersionFormat, VersionFormat.Semver);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NUnit.Framework;
using Octopus.Core.Resources;
using Octopus.Core.Resources.Versioning;
using Octopus.Core.Resources.Versioning.Factories;

namespace Octopus.Server.Core.Versioning.Tests.Versions
Expand Down Expand Up @@ -84,7 +85,7 @@ public void TestEquilivants()
[Test]
public void TestInvalidVersion()
{
Assert.False(VersionFactory.TryCreateVersion("1.0.*", out var version, FeedType.NuGet));
Assert.False(VersionFactory.TryCreateVersion("1.0.*", out var version, VersionFormat.Semver));
}
}
}
8 changes: 0 additions & 8 deletions source/Octopus.Server.Core.Versioning/Class1.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Octopus\Core\Constants\JavaConstants.cs" />
<Compile Include="Octopus\Core\Constants\ServerConstants.cs" />
<Compile Include="Octopus\Core\FeedType.cs" />
<Compile Include="Octopus\Core\Resources\Versioning\FeedType.cs" />
<Compile Include="Octopus\Core\Resources\Metadata\BasePackageMetadata.cs" />
<Compile Include="Octopus\Core\Resources\Metadata\IMetadataFactory.cs" />
<Compile Include="Octopus\Core\Resources\Metadata\MavenPackageIDParser.cs" />
Expand Down
45 changes: 0 additions & 45 deletions source/Octopus.Server.Core.Versioning/Octopus/Core/FeedType.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Octopus.Core.Resources.Versioning;

namespace Octopus.Core.Resources
{
Expand All @@ -10,7 +11,7 @@ public class BasePackageMetadata
public string PackageId { get; set; }

[JsonIgnore]
public FeedType FeedType { get; set; }
public VersionFormat VersionFormat { get; set; }

/// <summary>
/// Used to define the search pattern for files on the target base only
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Octopus.Core.Util;
using Octopus.Core.Resources.Versioning;
using Octopus.Core.Util;

namespace Octopus.Core.Resources.Metadata
{
Expand All @@ -14,27 +15,27 @@ public interface IMetadataFactory : IPackageIDParser
/// Extracts metadata from a package ID (i.e. no version information)
/// </summary>
/// <param name="packageID">The package id</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package id</returns>
BasePackageMetadata GetMetadataFromPackageID(string packageID, FeedType feedType);
BasePackageMetadata GetMetadataFromPackageID(string packageID, VersionFormat format);
/// <summary>
/// Returns true or false based on whether or not we can parse the
/// supplied package id.
/// </summary>
/// <param name="packageID">The package id</param>
/// <param name="metadata">The parsed metadata if we returned true</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>True if this package id could be parsed</returns>
bool TryGetMetadataFromPackageID(string packageID, out BasePackageMetadata metadata, FeedType feedType);
bool TryGetMetadataFromPackageID(string packageID, out BasePackageMetadata metadata, VersionFormat format);
/// <summary>
/// Extracts metadata from a package ID and adds the supplied version and extension
/// </summary>
/// <param name="packageID">The package id</param>
/// <param name="version">The package version</param>
/// <param name="extension">The package extension</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package id</returns>
PackageMetadata GetMetadataFromPackageID(string packageID, string version, string extension, FeedType feedType);
PackageMetadata GetMetadataFromPackageID(string packageID, string version, string extension, VersionFormat format);
/// <summary>
/// Extracts metadata from a package ID and adds the supplied version and extension
/// </summary>
Expand All @@ -43,9 +44,9 @@ public interface IMetadataFactory : IPackageIDParser
/// <param name="extension">The package extension</param>
/// <param name="size">The file size</param>
/// <param name="hash">The file hash</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package id</returns>
PhysicalPackageMetadata GetMetadataFromPackageID(string packageID, string version, string extension, long size, string hash, FeedType feedType);
PhysicalPackageMetadata GetMetadataFromPackageID(string packageID, string version, string extension, long size, string hash, VersionFormat format);
/// <summary>
/// The target Files cache has filenames like
/// "com.google.guava#guava#23.3-jre.jar-e55fcd51-6081-4300-91a3-117b7930c023" or
Expand All @@ -55,9 +56,9 @@ public interface IMetadataFactory : IPackageIDParser
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package file</returns>
PackageMetadata GetMetadataFromPackageName(string packageFile, string[] extensions, FeedType feedType);
PackageMetadata GetMetadataFromPackageName(string packageFile, string[] extensions, VersionFormat format);
/// <summary>
/// The target Files cache has filenames like
/// "com.google.guava#guava#23.3-jre.jar-e55fcd51-6081-4300-91a3-117b7930c023" or
Expand All @@ -68,9 +69,9 @@ public interface IMetadataFactory : IPackageIDParser
/// <param name="packageFile">The package file name</param>
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="packageMetadata">The package metadata if the parsing was successful</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>True if the file could be parsed, and false otherwise</returns>
bool TryGetMetadataFromPackageName(string packageFile, string[] extensions, out PackageMetadata packageMetadata, FeedType feedType);
bool TryGetMetadataFromPackageName(string packageFile, string[] extensions, out PackageMetadata packageMetadata, VersionFormat format);
/// <summary>
/// The target Files cache has filenames like
/// "com.google.guava#guava#23.3-jre.jar-e55fcd51-6081-4300-91a3-117b7930c023" or
Expand All @@ -80,9 +81,9 @@ public interface IMetadataFactory : IPackageIDParser
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>A tuple with a boolean indicating the success of the parsing, and the metadata if parsing was successful</returns>
Maybe<PackageMetadata> TryGetMetadataFromPackageName(string packageFile, string[] extensions, FeedType feedType);
Maybe<PackageMetadata> TryGetMetadataFromPackageName(string packageFile, string[] extensions, VersionFormat format);
/// <summary>
/// The target Files cache has filenames like
/// "com.google.guava#guava#23.3-jre.jar-e55fcd51-6081-4300-91a3-117b7930c023" or
Expand All @@ -91,9 +92,9 @@ public interface IMetadataFactory : IPackageIDParser
/// This method will break down these filenames.
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>A tuple with a boolean indicating the success of the parsing, and the metadata if parsing was successful</returns>
Maybe<PackageMetadata> TryGetMetadataFromPackageName(string packageFile, FeedType feedType);
Maybe<PackageMetadata> TryGetMetadataFromPackageName(string packageFile, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
Expand All @@ -102,19 +103,19 @@ public interface IMetadataFactory : IPackageIDParser
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package file</returns>
PackageMetadata GetMetadataFromServerPackageName(string packageFile, string[] extensions, FeedType feedType);
PackageMetadata GetMetadataFromServerPackageName(string packageFile, string[] extensions, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
/// "mypackage.1.0.0.0_BA90F59B8C9EE04DADE2D3501181EFCD.nuget".
/// This method will break down this filename.
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package file</returns>
PackageMetadata GetMetadataFromServerPackageName(string packageFile, FeedType feedType);
PackageMetadata GetMetadataFromServerPackageName(string packageFile, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
Expand All @@ -124,29 +125,29 @@ public interface IMetadataFactory : IPackageIDParser
/// <param name="packageFile">The package file name</param>
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="packageMetadata">The package metadata if the parsing was successful</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>True if the file could be parsed, and false otherwise</returns>
bool TryGetMetadataFromServerPackageName(string packageFile, string[] extensions, out PackageMetadata packageMetadata, FeedType feedType);
bool TryGetMetadataFromServerPackageName(string packageFile, string[] extensions, out PackageMetadata packageMetadata, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
/// "mypackage.1.0.0.0_BA90F59B8C9EE04DADE2D3501181EFCD.nuget".
/// This method will break down this filename.
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>A tuple with a boolean indicating the success of the parsing, and the metadata if parsing was successful</returns>
Maybe<PackageMetadata> TryGetMetadataFromServerPackageName(string packageFile, string[] extensions, FeedType feedType);
Maybe<PackageMetadata> TryGetMetadataFromServerPackageName(string packageFile, string[] extensions, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
/// "mypackage.1.0.0.0_BA90F59B8C9EE04DADE2D3501181EFCD.nuget".
/// This method will break down this filename.
/// </summary>
/// <param name="packageFile">The package file name</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>A tuple with a boolean indicating the success of the parsing, and the metadata if parsing was successful</returns>
Maybe<PackageMetadata> TryGetMetadataFromServerPackageName(string packageFile, FeedType feedType);
Maybe<PackageMetadata> TryGetMetadataFromServerPackageName(string packageFile, VersionFormat format);
/// <summary>
/// The server side cache has filenames like
/// "com.google.guava#guava#23.3-jre_9822965F2883AD43AD79DA4E8795319F.jar" or
Expand All @@ -157,13 +158,13 @@ public interface IMetadataFactory : IPackageIDParser
/// <param name="extensions">The extensions that this parser should know about</param>
/// <param name="size">The file size</param>
/// <param name="hash">The file hash</param>
/// <param name="feedType">The type of feed that supplied the package</param>
/// <param name="format">The version format used by the package</param>
/// <returns>The metadata assocaited with the package file</returns>
PhysicalPackageMetadata GetMetadataFromServerPackageName(
string packageFile,
string[] extensions,
long size,
string hash,
FeedType feedType);
VersionFormat versionFormat);
}
}
Loading

0 comments on commit 4484e73

Please sign in to comment.