-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Added check for Sentry.framework copy success (#496)
* check if file got copied * added tests * fixed expected exception * Format code * test cleanup Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
- Loading branch information
1 parent
ccf4fa7
commit 3fd4f4c
Showing
2 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/Sentry.Unity.Editor.iOS.Tests/BuildPostProcessorTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using Sentry.Unity.Tests.SharedClasses; | ||
|
||
namespace Sentry.Unity.Editor.iOS.Tests | ||
{ | ||
public class BuildPostProcessorTests | ||
{ | ||
private string _testDirectoryPath = null!; | ||
private string _sentryFrameworkPath = null!; | ||
private string _xcodeProjectPath = null!; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_testDirectoryPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString().Substring(0, 4)); | ||
_sentryFrameworkPath = Path.Combine(_testDirectoryPath, "Sentry.framework"); | ||
_xcodeProjectPath = Path.Combine(_testDirectoryPath, "XcodeProject"); | ||
|
||
Directory.CreateDirectory(_testDirectoryPath); | ||
Directory.CreateDirectory(_sentryFrameworkPath); | ||
Directory.CreateDirectory(_xcodeProjectPath); | ||
} | ||
|
||
[TearDown] | ||
public void TearDown() => Directory.Delete(_testDirectoryPath, true); | ||
|
||
[Test] | ||
public void CopyFrameworkToBuildDirectory_CopiesFramework() | ||
{ | ||
BuildPostProcess.CopyFrameworkToBuildDirectory(_xcodeProjectPath, _sentryFrameworkPath, new TestLogger()); | ||
|
||
Assert.IsTrue(Directory.Exists(Path.Combine(_xcodeProjectPath, "Frameworks", "Sentry.framework"))); | ||
} | ||
|
||
[Test] | ||
public void CopyFrameworkToBuildDirectory_FrameworkAlreadyCopied_LogsSkipMessage() | ||
{ | ||
var testLogger = new TestLogger(); | ||
|
||
BuildPostProcess.CopyFrameworkToBuildDirectory(_xcodeProjectPath, _sentryFrameworkPath, testLogger); | ||
BuildPostProcess.CopyFrameworkToBuildDirectory(_xcodeProjectPath, _sentryFrameworkPath, testLogger); | ||
|
||
Assert.IsTrue(testLogger.Logs.Any(log => | ||
log.logLevel == SentryLevel.Debug && | ||
log.message.Contains("'Sentry.framework' has already copied"))); | ||
} | ||
|
||
[Test] | ||
public void CopyFrameworkToBuildDirectory_FailedToCopyFramework_ThrowsFileNotFoundException() => | ||
Assert.Throws<FileNotFoundException>(() => | ||
BuildPostProcess.CopyFrameworkToBuildDirectory(_xcodeProjectPath, "non-existent-path", new TestLogger())); | ||
} | ||
} |