예제 #1
0
        public async Task CopyRepository_TargetExistsLocally_InitialCloneMoved()
        {
            // Arrange
            string developer        = "testUser";
            string org              = "ttd";
            string sourceRepository = "apps-test";
            string targetRepository = "apps-test-2021";

            try
            {
                PrepareRemoteTestData(org, sourceRepository);
                TestDataHelper.CleanUpRemoteRepository("ttd", "apps-test-2021");
                await TestDataHelper.CleanUpReplacedRepositories(org, targetRepository, developer);

                RepositorySI sut = GetServiceForTest(developer);

                // Act
                await sut.CopyRepository(org, sourceRepository, targetRepository, developer);

                // Assert
                string developerClonePath = Path.Combine(TestDataHelper.GetTestDataRepositoriesRootDirectory(), developer, org);
                int    actualCloneCount   = Directory.GetDirectories(developerClonePath).Count(d => d.Contains("apps-test-2021"));
                Assert.Equal(2, actualCloneCount);
            }
            finally
            {
                TestDataHelper.CleanUpRemoteRepository("ttd", "apps-test-2021");
                await TestDataHelper.CleanUpReplacedRepositories(org, targetRepository, developer);

                CleanUpRemoteTestData(org, sourceRepository);
            }
        }
예제 #2
0
        public async Task CopyRepository_TargetDoesNotExistsLocally()
        {
            // Arrange
            string developer        = "testUser";
            string org              = "ttd";
            string sourceRepository = "apps-test";
            string targetRepository = "apps-test-clone";
            string expectedRepoPath = TestDataHelper.GetTestDataRepositoryDirectory(org, targetRepository, developer);

            try
            {
                PrepareRemoteTestData(org, sourceRepository);

                RepositorySI sut = GetServiceForTest(developer);

                // Act
                await sut.CopyRepository(org, sourceRepository, targetRepository, developer);

                // Assert
                string appMetadataString  = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, "App/config/applicationmetadata.json");
                string gitConfigString    = TestDataHelper.GetFileFromRepo(org, targetRepository, developer, ".git/config");
                string developerClonePath = Path.Combine(TestDataHelper.GetTestDataRepositoriesRootDirectory(), developer, org);

                Assert.True(Directory.Exists(expectedRepoPath));
                Assert.Contains("\"id\": \"ttd/apps-test-clone\"", appMetadataString);
                Assert.Contains("https://dev.altinn.studio/repos/ttd/apps-test-clone.git", gitConfigString);
                Assert.DoesNotContain(Directory.GetDirectories(developerClonePath), a => a.Contains("_COPY_OF_ORIGIN_"));
            }
            finally
            {
                string path = TestDataHelper.GetTestDataRepositoryDirectory("ttd", "apps-test-clone", "testUser");
                TestDataHelper.CleanUpRemoteRepository(org, targetRepository);
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }

                CleanUpRemoteTestData(org, sourceRepository);
            }
        }