Ejemplo n.º 1
0
        public async Task WriteTextByRelativePathAsync_ReadWriteRoundtrip_ShouldReadBackEqual(string expectedFilePath)
        {
            var org = "ttd";
            var sourceRepository = "hvem-er-hvem";
            var developer        = "testUser";
            var targetRepository = Guid.NewGuid().ToString();

            string repositoriesRootDirectory = TestDataHelper.GetTestDataRepositoriesRootDirectory();
            var    repositoryDirectory       = await TestDataHelper.CopyRepositoryForTest(org, sourceRepository, developer, targetRepository);

            var gitRepository = new Altinn.Studio.Designer.Infrastructure.GitRepository.GitRepository(repositoriesRootDirectory, repositoryDirectory);

            var expectedContent = await gitRepository.ReadTextByRelativePathAsync(expectedFilePath);

            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);
            }
        }
Ejemplo n.º 2
0
        public Task <bool> DeleteRepository(string org, string repository)
        {
            string remotePath = TestDataHelper.GetTestDataRemoteRepository(org, repository);

            TestDataHelper.DeleteDirectory(remotePath, true);

            return(Task.FromResult(true));
        }
Ejemplo n.º 3
0
        public async Task WriteTextByRelativePathAsync_PathDontExist_ShouldCreateDirectory()
        {
            Altinn.Studio.Designer.Infrastructure.GitRepository.GitRepository gitRepository = GetTestRepository("ttd", "hvem-er-hvem", "testUser");

            var relativeFileUrl = "test_directory/should/be/created/deleteme.txt";

            Assert.False(gitRepository.FileExistsByRelativePath(relativeFileUrl));

            await gitRepository.WriteTextByRelativePathAsync(relativeFileUrl, "this file should be here", true);

            Assert.True(gitRepository.FileExistsByRelativePath(relativeFileUrl));

            TestDataHelper.DeleteDirectory(Path.Join(gitRepository.RepositoryDirectory, "test_directory"));
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }