public async Task WriteTextByRelativePathAsync_PathDontExist_ShouldCreateDirectory() { var repositoriesRootDirectory = TestDataHelper.GetTestDataRepositoriesRootDirectory(); var repositoryDirectory = TestDataHelper.CreateEmptyRepositoryForTest("ttd", Guid.NewGuid().ToString(), "testUser"); var gitRepository = new Altinn.Studio.Designer.Infrastructure.GitRepository.GitRepository(repositoriesRootDirectory, repositoryDirectory); var relativeFileUrl = "test_directory/should/be/created/deleteme.txt"; Assert.False(gitRepository.FileExistsByRelativePath(relativeFileUrl)); try { await gitRepository.WriteTextByRelativePathAsync(relativeFileUrl, "this file should be here", true); Assert.True(gitRepository.FileExistsByRelativePath(relativeFileUrl)); } finally { TestDataHelper.DeleteDirectory(repositoryDirectory); } }
public async Task WriteTextByRelativePathAsync_ValidText_ShouldReadBackEqual(string expectedContent) { string repositoriesRootDirectory = TestDataHelper.GetTestDataRepositoriesRootDirectory(); string repositoryDirectory = TestDataHelper.CreateEmptyRepositoryForTest("ttd", Guid.NewGuid().ToString(), "testUser"); var gitRepository = new Altinn.Studio.Designer.Infrastructure.GitRepository.GitRepository(repositoriesRootDirectory, repositoryDirectory); var filename = $"{Guid.NewGuid()}.json"; try { await gitRepository.WriteTextByRelativePathAsync(filename, expectedContent); var actualContent = await gitRepository.ReadTextByRelativePathAsync(filename); Assert.Equal(expectedContent, actualContent); } finally { TestDataHelper.DeleteDirectory(repositoryDirectory); } }