Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcmarrow committed Aug 29, 2023
1 parent 5a5adfe commit e2d43b0
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/pytests/functional/pillar/test_git_pillar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import copy

import pytest

from salt.pillar.git_pillar import ext_pillar
Expand Down Expand Up @@ -32,7 +30,7 @@

@pytest.fixture
def git_pillar_opts(salt_master, tmp_path):
opts = dict(copy.deepcopy(salt_master.config))
opts = dict(salt_master.config)
opts["cachedir"] = str(tmp_path)
return opts

Expand Down Expand Up @@ -228,3 +226,31 @@ def test_gitpython_multiple(gitpython_pillar_opts, grains):
@skipif_no_pygit2
def test_pygit2_multiple(pygit2_pillar_opts, grains):
_test_multiple(pygit2_pillar_opts, grains)


def _test_multiple_2(pillar_opts, grains):
data = _get_ext_pillar(
"minion",
pillar_opts,
grains,
"https://github.com/saltstack/salt-test-pillar-gitfs.git",
"https://github.com/saltstack/salt-test-pillar-gitfs-2.git",
)
assert data == {
"key": "value",
"key1": "value1",
"key2": "value2",
"key4": "value4",
"data1": "d",
"data2": "d2",
}


@skipif_no_gitpython
def test_gitpython_multiple_2(gitpython_pillar_opts, grains):
_test_multiple_2(gitpython_pillar_opts, grains)


@skipif_no_pygit2
def test_pygit2_multiple_2(pygit2_pillar_opts, grains):
_test_multiple_2(pygit2_pillar_opts, grains)
62 changes: 62 additions & 0 deletions tests/pytests/functional/utils/test_gifts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pytest

from salt.utils.gitfs import GitFS

pytestmark = [
pytest.mark.slow_test,
]


try:
import git # pylint: disable=unused-import

HAS_GITPYTHON = True
except ImportError:
HAS_GITPYTHON = False


try:
import pygit2 # pylint: disable=unused-import

HAS_PYGIT2 = True
except ImportError:
HAS_PYGIT2 = False


skipif_no_gitpython = pytest.mark.skipif(not HAS_GITPYTHON, reason="Missing gitpython")
skipif_no_pygit2 = pytest.mark.skipif(not HAS_PYGIT2, reason="Missing pygit2")


@pytest.fixture
def gitfs_opts(salt_factories, tmp_path):
config_defaults = {"cachedir": str(tmp_path)}
factory = salt_factories.salt_master_daemon(
"gitfs-functional-master", defaults=config_defaults
)
return dict(factory.config)


@pytest.fixture
def gitpython_gifts_opts(gitfs_opts):
gitfs_opts["verified_gifts_provider"] = "gitpython"
return gitfs_opts


@pytest.fixture
def pygit2_gifts_opts(gitfs_opts):
gitfs_opts["verified_gifts_provider"] = "pygit2"
return gitfs_opts


def _test_gitfs_simple(gitfs_opts):
g = GitFS(gitfs_opts, ["https://github.com/saltstack/salt-test-pillar-gitfs.git"])


# @skipif_no_gitpython
# def test_gitpython_gitfs_simple(gitpython_gifts_opts):
# _test_gitfs_simple(gitpython_gifts_opts)


# @skipif_no_pygit2
# def test_pygit2_gitfs_simple(pygit2_gifts_opts):
# _test_gitfs_simple(pygit2_gifts_opts)

0 comments on commit e2d43b0

Please sign in to comment.