File: bw_apply_git_deploy.py

package info (click to toggle)
bundlewrap 4.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,216 kB
  • sloc: python: 20,299; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 2,087 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from os.path import exists, join

from bundlewrap.utils.testing import host_os, make_repo, run


def test_deploy_from_url(tmpdir):
    make_repo(
        tmpdir,
        bundles={
            "test": {
                'items': {
                    'git_deploy': {
                        join(str(tmpdir), "git_deployed_bw"): {
                            'repo': "https://github.com/bundlewrap/bundlewrap.git",
                            'rev': "main",
                        },
                    },
                    'directories': {
                        join(str(tmpdir), "git_deployed_bw"): {},
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    assert not exists(join(str(tmpdir), "git_deployed_bw", "LICENSE"))
    stdout, stderr, rcode = run("bw apply localhost", path=str(tmpdir))
    assert rcode == 0
    assert exists(join(str(tmpdir), "git_deployed_bw", "LICENSE"))
    assert not exists(join(str(tmpdir), "git_deployed_bw", ".git"))


def test_cannot_deploy_into_purged(tmpdir):
    make_repo(
        tmpdir,
        bundles={
            "test": {
                'items': {
                    'git_deploy': {
                        join(str(tmpdir), "git_deployed_bw"): {
                            'repo': "https://github.com/bundlewrap/bundlewrap.git",
                            'rev': "main",
                        },
                    },
                    'directories': {
                        join(str(tmpdir), "git_deployed_bw"): {
                            'purge': True,
                        },
                    },
                },
            },
        },
        nodes={
            "localhost": {
                'bundles': ["test"],
                'os': host_os(),
            },
        },
    )

    stdout, stderr, rcode = run("bw apply localhost", path=str(tmpdir))
    assert rcode == 1
    assert b"cannot git_deploy into purged directory" in stderr