Example #1
0
    def test_deploy_release(self, m_tag, m_bash,
                            victim_release: DockerImageBuilder):
        files = [
            DockerFile("Dockerfile", None, None, None, True),
            DockerFile("File2", "-foo", None, "mycustom/repo", False)
        ]

        victim_release.deploy(files)
        build_call_1 = [
            "docker", "build", "--build-arg",
            "PIP_EXTRA_INDEX_URL=url/to/artifact/store", "-t",
            "pony/myapp:2.1.0", "-f", "./Dockerfile", "."
        ]
        build_call_2 = [
            "docker", "build", "--build-arg",
            "PIP_EXTRA_INDEX_URL=url/to/artifact/store", "-t",
            "mycustom/repo-foo:2.1.0", "-f", "./File2", "."
        ]

        push_call_1 = ["docker", "push", "pony/myapp:2.1.0"]
        tag_call_latest = [
            "docker", "tag", "pony/myapp:2.1.0", "pony/myapp:latest"
        ]
        push_call_1_latest = ["docker", "push", "pony/myapp:latest"]
        push_call_2 = ["docker", "push", "mycustom/repo-foo:2.1.0"]
        calls = list(
            map(mock.call, [
                build_call_1, push_call_1, tag_call_latest, push_call_1_latest,
                build_call_2, push_call_2
            ]))
        m_bash.assert_has_calls(calls)
    def test_deploy_non_release(self, m_tag, m_bash, victim: DockerImageBuilder):
        files = [DockerFile("Dockerfile", None, 'name', None, True), DockerFile("File2", "-foo", None, "mycustom/repo", False)]
        victim.deploy(files)
        build_call_1 = ["docker", "build", "--build-arg", "PIP_EXTRA_INDEX_URL=url/to/artifact/store", "-t", "pony/name/myapp:SNAPSHOT", "-f", "./Dockerfile", "."]
        build_call_2 = ["docker", "build", "--build-arg", "PIP_EXTRA_INDEX_URL=url/to/artifact/store", "-t", "mycustom/repo-foo:SNAPSHOT", "-f", "./File2", "."]

        push_call_1 = ["docker", "push", "pony/name/myapp:SNAPSHOT"]
        push_call_2 = ["docker", "push", "mycustom/repo-foo:SNAPSHOT"]
        calls = list(map(mock.call, [build_call_1, push_call_1, build_call_2, push_call_2]))
        m_bash.assert_has_calls(calls)