Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/deploy-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ jobs:
if ("${{ vars.NUGET_PUBLISH_USER }}" -ne "") {
Write-Host "Using username and API key authentication for environment: $publishEnv"

# Remove existing source if it exists to avoid conflicts
dotnet nuget remove source $publishEnv 2>$null
# Use unique source name based on GitHub run ID
$uniqueSourceName = "$publishEnv-${{ github.run_id }}"

# Add the NuGet source configuration
dotnet nuget add source ${{ env.NUGET_PACKAGE_REPOSITORY }} `
--name $publishEnv `
--name $uniqueSourceName `
--username ${{ vars.NUGET_PUBLISH_USER }} `
--password ${{ secrets.NUGET_PUBLISH_API_KEY }} `
--store-password-in-clear-text

# Push the package using the configured source
dotnet nuget push Tableau.Migration.*.nupkg -s $publishEnv
# Push the package
dotnet nuget push Tableau.Migration.*.nupkg -s $uniqueSourceName

# Clean up temporary source
dotnet nuget remove source $uniqueSourceName
}
else {
Write-Host "Using API key only authentication for environment: $publishEnv"
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<Version>5.3.0</Version>
<Version>5.3.1</Version>
<Authors>Salesforce, Inc.</Authors>
<Company>Salesforce, Inc.</Company>
<Copyright>Copyright (c) 2025, Salesforce, Inc. and its licensors</Copyright>
Expand Down
2 changes: 1 addition & 1 deletion src/Tableau.Migration/Resources/SharedResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Owner with ID {OwnerID}: {owner}</value>
<value>Skipping migration of {ContentType} since it is disabled.</value>
</data>
<data name="ContentTypeDisabledReason" xml:space="preserve">
<value>{ContentType} are disabled at the {Endpoints}. {ContentType} will not be migrated.</value>
<value>{ContentType} are disabled at the {Endpoints}. No items for this content type will be migrated.</value>
</data>
<data name="HasManagedOAuthCredentialsWarning" xml:space="preserve">
<value>Embedded Managed OAuth Credentials migration is not supported. They will be converted to saved credentials for {0} {1} at {2}. The connection IDs are {3}.</value>
Expand Down
11 changes: 8 additions & 3 deletions tests/Tableau.Migration.Tests/FixtureFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ public static class FixtureFactory
public static IFixture Create() => Customize(new Fixture());

private static IFixture Customize(IFixture fixture)
{
fixture = fixture.Customize(new AutoMoqCustomization { ConfigureMembers = true });

{
fixture.Customizations.Add(new ImmutableCollectionSpecimenBuilder());
fixture.Customizations.Add(new PageInfoSpecimenBuilder());
fixture.Customizations.Add(new LoggerSpecimenBuilder());

fixture = fixture.Customize(new AutoMoqCustomization { ConfigureMembers = true });

fixture.Register<IFileSystem>(() => new MockFileSystem());

Expand Down Expand Up @@ -331,6 +332,10 @@ string GetRandomExtractType()

fixture.Register<MemoryCacheOptions>(() => new MemoryCacheOptions());

var mockSharedLocalizer = new MockSharedResourcesLocalizer();
fixture.Register<ISharedResourcesLocalizer>(() => mockSharedLocalizer.Object);
fixture.Register<Mock<ISharedResourcesLocalizer>>(() => mockSharedLocalizer);

return fixture;
}

Expand Down
81 changes: 81 additions & 0 deletions tests/Tableau.Migration.Tests/LoggerSpecimenBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// Copyright (c) 2025, Salesforce, Inc.
// SPDX-License-Identifier: Apache-2
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

using System;
using System.Linq;
using AutoFixture.Kernel;
using Microsoft.Extensions.Logging;
using Moq;

namespace Tableau.Migration.Tests
{
internal sealed class LoggerSpecimenBuilder : ISpecimenBuilder
{
private readonly TestLoggerFactory _loggerFactory;

public LoggerSpecimenBuilder()
{
_loggerFactory = new();
}

public object Create(object request, ISpecimenContext context)
{
if (request is not Type t)
{
return new NoSpecimen();
}

if(t == typeof(TestLoggerFactory) || t == typeof(Mock<ILoggerFactory>))
{
return _loggerFactory;
}
else if(t == typeof(ILoggerFactory))
{
return _loggerFactory.Object;
}
else if(t == typeof(Mock<ILogger>))
{
return _loggerFactory.DefaultLogger;
}
else if(t == typeof(ILogger))
{
return _loggerFactory.DefaultLogger.Object;
}
else if(t.IsGenericType)
{
var genericType = t.GetGenericTypeDefinition();

if (genericType == typeof(ILogger<>))
{
return typeof(TestLoggerFactory).GetMethod(nameof(TestLoggerFactory.CreateTestLogger))
!.MakeGenericMethod(t.GenericTypeArguments.Single()).Invoke(_loggerFactory, null)!;
}
else if(genericType == typeof(Mock<>))
{
var mockType = t.GenericTypeArguments.First();
if(mockType.IsGenericType && mockType.GetGenericTypeDefinition() == typeof(ILogger<>))
{
return typeof(TestLoggerFactory).GetMethod(nameof(TestLoggerFactory.CreateTestLogger))
!.MakeGenericMethod(mockType.GenericTypeArguments.Single()).Invoke(_loggerFactory, null)!;
}
}
}

return new NoSpecimen();
}
}
}
12 changes: 10 additions & 2 deletions tests/Tableau.Migration.Tests/TestLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ namespace Tableau.Migration.Tests
{
public class TestLoggerFactory : Mock<ILoggerFactory>, ILoggerFactory
{
private readonly ConcurrentDictionary<string, TestLogger> _loggersByCategory = new();
private readonly ConcurrentDictionary<string, object> _loggersByCategory = new();

public TestLogger DefaultLogger => CreateTestLogger(string.Empty);

public TestLogger<T> CreateTestLogger<T>()
=> (TestLogger<T>)_loggersByCategory.GetOrAdd(typeof(T).FullName ?? string.Empty, _ => new TestLogger<T>());

private TestLogger CreateTestLogger(string category)
=> (TestLogger)_loggersByCategory.GetOrAdd(category, _ => new TestLogger());

public TestLoggerFactory()
{
Setup(f => f.CreateLogger(It.IsAny<string>()))
.Returns((string category) => _loggersByCategory.GetOrAdd(category, _ => new TestLogger()));
.Returns((string category) => CreateTestLogger(category).Object);
}

#region - ILoggerFactory -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,4 @@ public void SharedResourceKeys_and_SharedResources_are_in_sync()
}
}
}


}