-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit test for SopsConfigLoader to verify exception on missi…
…ng .sops.yaml file (#663) Signed-off-by: Nikolai Emil Damm <[email protected]>
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using KSail.Utils; | ||
|
||
namespace KSail.Tests.Utils; | ||
|
||
/// <summary> | ||
/// Tests for <see cref="SopsConfigLoader"/>. | ||
/// </summary> | ||
public class SopsConfigLoaderTest | ||
{ | ||
/// <summary> | ||
/// Test that <see cref="SopsConfigLoader.LoadAsync"/> throws <see cref="KSailException"/> when no '.sops.yaml' file is found. | ||
/// </summary> | ||
/// <returns></returns> | ||
[Fact] | ||
public async Task LoadAsync_NoSopsYamlFile_ThrowsKSailException() | ||
{ | ||
// Arrange | ||
string testDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
_ = Directory.CreateDirectory(testDirectory); | ||
|
||
try | ||
{ | ||
// Act & Assert | ||
var exception = await Assert.ThrowsAsync<KSailException>(() => SopsConfigLoader.LoadAsync(testDirectory)); | ||
Assert.Equal("'.sops.yaml' file not found in the current or parent directories", exception.Message); | ||
} | ||
finally | ||
{ | ||
// Cleanup | ||
Directory.Delete(testDirectory, true); | ||
} | ||
} | ||
} |