2022-03-10 13:05:34 +03:00
|
|
|
import pytest
|
|
|
|
import nix_ffi
|
|
|
|
|
|
|
|
exampleDreamLock = dict(
|
|
|
|
_generic = dict(
|
|
|
|
defaultPackage="example",
|
|
|
|
packages=dict(
|
|
|
|
example="1.2.3",
|
|
|
|
),
|
|
|
|
subsystem = "nodejs",
|
|
|
|
_subsystemAttrs = {},
|
|
|
|
),
|
|
|
|
dependencies = {},
|
|
|
|
cyclicDependencies = {},
|
2022-07-12 13:33:04 +03:00
|
|
|
sources = dict(
|
|
|
|
example = {
|
|
|
|
"1.2.3": dict(
|
|
|
|
type = "path",
|
|
|
|
rootName = None,
|
|
|
|
rootVersion = None,
|
|
|
|
relPath = "a/b/c",
|
|
|
|
),
|
|
|
|
},
|
|
|
|
),
|
2022-03-10 13:05:34 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_dream_lock_inject():
|
|
|
|
result = nix_ffi.callNixFunction(
|
|
|
|
'utils.dreamLock.injectDependencies',
|
|
|
|
dreamLock=exampleDreamLock,
|
|
|
|
inject=dict(
|
|
|
|
example={
|
|
|
|
"1.2.3": [
|
|
|
|
[ "injected-package", "1.0.0" ]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
),
|
|
|
|
)
|
|
|
|
assert result['dependencies']['example']['1.2.3'] == [dict(
|
|
|
|
name="injected-package",
|
|
|
|
version="1.0.0",
|
|
|
|
)]
|
2022-07-12 13:33:04 +03:00
|
|
|
|
|
|
|
def test_dream_lock_replace_root_sources():
|
|
|
|
result = nix_ffi.callNixFunction(
|
|
|
|
'utils.dreamLock.replaceRootSources',
|
|
|
|
dreamLock=exampleDreamLock,
|
|
|
|
newSourceRoot=dict(
|
|
|
|
type = "http",
|
|
|
|
url = "something",
|
|
|
|
),
|
|
|
|
)
|
|
|
|
assert result['sources']['example']['1.2.3'] == dict(
|
|
|
|
type = "http",
|
|
|
|
url = "something",
|
|
|
|
dir = "a/b/c",
|
|
|
|
)
|