示例#1
0
    def test_get_projects_yaml(self):
        """Testing get_projects() yaml get_schedule()."""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
                Repository('project.yaml', 'file',
                           'projects/test0/project.yaml')
            ]),
            Repository('test1', 'dir', 'projects/test1', [
                Repository('Dockerfile', 'file', 'projects/test1/Dockerfile'),
                Repository('project.yaml', 'file',
                           'projects/test1/project.yaml')
            ])
        ])
        repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 2')
        repo.contents[1].contents[1].set_yaml_contents(b'builds_per_day: 3')

        self.assertEqual(
            get_projects(repo), {
                'test0':
                ProjectMetadata('0 6,18 * * *', 'builds_per_day: 2',
                                'name: test'),
                'test1':
                ProjectMetadata('0 6,14,22 * * *', 'builds_per_day: 3',
                                'name: test')
            })
示例#2
0
    def test_get_projects_non_directory_type_project(self):
        """Testing get_projects() when a file in projects/ is not of type 'dir'."""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile')
            ]),
            Repository('test1', 'file', 'projects/test1')
        ])

        self.assertEqual(get_projects(repo), {'test0'})
示例#3
0
    def test_get_projects_no_docker_file(self):
        """Testing get_projects() with missing dockerfile"""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile')
            ]),
            Repository('test1', 'dir', 'projects/test1')
        ])

        self.assertEqual(get_projects(repo), {'test0'})
示例#4
0
    def test_yaml_out_of_range(self):
        """Testing invalid yaml schedule parameter argument."""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
                Repository('project.yaml', 'file',
                           'projects/test0/project.yaml')
            ])
        ])
        repo.contents[0].contents[1].set_yaml_contents(b'builds_per_day: 5')

        self.assertEqual(get_projects(repo), {})
示例#5
0
    def test_get_projects_invalid_project_name(self):
        """Testing get_projects() with invalid project name"""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile')
            ]),
            Repository('test1@', 'dir', 'projects/test1', [
                Repository('Dockerfile', 'file', 'projects/test1/Dockerfile')
            ])
        ])

        self.assertEqual(get_projects(repo), {'test0'})
示例#6
0
    def test_get_projects(self):
        """Testing get_projects()."""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile')
            ]),
            Repository('test1', 'dir', 'projects/test1', [
                Repository('Dockerfile', 'file', 'projects/test1/Dockerfile')
            ])
        ])

        self.assertEqual(get_projects(repo), {'test0', 'test1'})
示例#7
0
    def test_get_projects_non_directory_type_project(self):
        """Testing get_projects() when a file in projects/ is not of type 'dir'."""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
                Repository('project.yaml', 'file',
                           'projects/test0/project.yaml')
            ]),
            Repository('test1', 'file', 'projects/test1')
        ])

        self.assertEqual(get_projects(repo), {
            'test0':
            ProjectMetadata('0 6 * * *', 'name: test', 'name: test')
        })
示例#8
0
    def test_get_projects_no_docker_file(self):
        """Testing get_projects() with missing dockerfile"""

        repo = Repository('oss-fuzz', 'dir', 'projects', [
            Repository('test0', 'dir', 'projects/test0', [
                Repository('Dockerfile', 'file', 'projects/test0/Dockerfile'),
                Repository('project.yaml', 'file',
                           'projects/test0/project.yaml')
            ]),
            Repository('test1', 'dir', 'projects/test1')
        ])

        self.assertEqual(get_projects(repo), {
            'test0':
            ProjectMetadata('0 6 * * *', 'name: test', 'name: test')
        })