-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from getsentry/feat/environment-options
Add Environment to SentryOptions
- Loading branch information
Showing
7 changed files
with
123 additions
and
16 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
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,14 @@ | ||
using System; | ||
|
||
namespace Sentry.Internal | ||
{ | ||
internal static class EnvironmentLocator | ||
{ | ||
/// <summary> | ||
/// Attempts to locate the environment the app is running in | ||
/// </summary> | ||
/// <returns>The Environment name or null, if it couldn't be located.</returns> | ||
public static string GetCurrent() | ||
=> Environment.GetEnvironmentVariable(Constants.EnvironmentEnvironmentVariable); | ||
} | ||
} |
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
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
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
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,34 @@ | ||
using Sentry.Internal; | ||
using Sentry.Tests.Helpers; | ||
using Xunit; | ||
|
||
namespace Sentry.Tests.Internals | ||
{ | ||
public class EnvironmentLocatorTests | ||
{ | ||
[Fact] | ||
public void GetCurrent_WithEnvironmentVariable_ReturnsEnvironmentVariableValue() | ||
{ | ||
const string expectedVersion = "the environment name"; | ||
EnvironmentVariableGuard.WithVariable( | ||
Constants.EnvironmentEnvironmentVariable, | ||
expectedVersion, | ||
() => | ||
{ | ||
Assert.Equal(expectedVersion, EnvironmentLocator.GetCurrent()); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void GetCurrent_WithoutEnvironmentVariable_ReturnsNull() | ||
{ | ||
EnvironmentVariableGuard.WithVariable( | ||
Constants.ReleaseEnvironmentVariable, | ||
null, | ||
() => | ||
{ | ||
Assert.Null(EnvironmentLocator.GetCurrent()); | ||
}); | ||
} | ||
} | ||
} |
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