예제 #1
0
 def test_directory(self):
     """git with non-default directory to clone into"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git',
             directory='hpccm'),
         'mkdir -p /tmp && cd /tmp && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpccm && cd -'
     )
예제 #2
0
 def test_opts(self):
     """git with non-default command line options"""
     g = git(opts=['--single-branch'])
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git'
         ),
         'mkdir -p /tmp && cd /tmp && git clone --single-branch https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
     )
예제 #3
0
 def test_commit(self):
     """git with specified commit"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git',
             commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c'),
         'mkdir -p /tmp && cd /tmp && git clone  https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c && cd -'
     )
예제 #4
0
 def test_path(self):
     """git with non-default base path"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git',
             path='/scratch'),
         'mkdir -p /scratch && cd /scratch && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
     )
예제 #5
0
 def test_branch(self):
     """git with specified branch"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git',
             branch='master'),
         'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch master https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
     )
예제 #6
0
 def test_basic(self):
     """Basic git"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git'
         ),
         'mkdir -p /tmp && cd /tmp && git clone --depth=1 https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
     )
예제 #7
0
 def test_branch_and_commit(self):
     """git with both specified branch and specified commit"""
     g = git()
     self.assertEqual(
         g.clone_step(
             repository='https://github.com/NVIDIA/hpc-container-maker.git',
             branch='master',
             commit='ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c'),
         'mkdir -p /tmp && git -C /tmp clone  https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && git -C /tmp/hpc-container-maker checkout ac6ca95d0b20ed1efaffa6d58945a4dd2d80780c'
     )
예제 #8
0
    def test_verify(self):
        """git with verification enabled"""
        g = git()
        repository = 'https://github.com/NVIDIA/hpc-container-maker.git'
        valid_branch = 'master'
        invalid_branch = 'does_not_exist'
        valid_commit = '23996b03b3e72f77a41498e94d90de920935644a'
        invalid_commit = 'deadbeef'

        self.assertEqual(
            g.clone_step(repository=repository,
                         branch=valid_branch,
                         verify=True),
            'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch master https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
        )

        self.assertEqual(
            g.clone_step(repository=repository,
                         branch=invalid_branch,
                         verify=True),
            'mkdir -p /tmp && cd /tmp && git clone --depth=1 --branch does_not_exist https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd -'
        )

        self.assertEqual(
            g.clone_step(repository=repository,
                         commit=valid_commit,
                         verify=True),
            'mkdir -p /tmp && cd /tmp && git clone  https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout 23996b03b3e72f77a41498e94d90de920935644a && cd -'
        )

        self.assertEqual(
            g.clone_step(repository=repository,
                         commit=invalid_commit,
                         verify=True),
            'mkdir -p /tmp && cd /tmp && git clone  https://github.com/NVIDIA/hpc-container-maker.git hpc-container-maker && cd - && cd /tmp/hpc-container-maker && git checkout deadbeef && cd -'
        )

        with self.assertRaises(RuntimeError):
            g.clone_step(repository=repository,
                         branch=invalid_branch,
                         verify='fatal')

        with self.assertRaises(RuntimeError):
            g.clone_step(repository=repository,
                         commit=invalid_commit,
                         verify='fatal')
예제 #9
0
 def test_missing_repo(self):
     """Missing repository option"""
     g = git()
     self.assertEqual(g.clone_step(), '')