-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_files_test.nix
89 lines (89 loc) · 2.35 KB
/
version_files_test.nix
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
let
lib = (builtins.getFlake (builtins.toString ./..)).lib;
in
[
{
name = ''
When neither versionsFile nor legacyVersionFiles are provided, then
throws an error
'';
actual = builtins.tryEval (lib.packagesFromVersionsFile { });
expected = { success = false; value = false; };
}
{
name = ''
When only legacyVersionFiles is provided, then returns the package
matching the requested version
'';
actual = lib.packagesFromVersionsFile {
legacyVersionFiles = {
python = builtins.toFile ".python-version" ''
3.12.0
'';
};
plugins = {
python = {
hasVersion = _: true;
packageFromVersion = { version, ... }: version;
};
};
};
expected = { python = "3.12.0"; };
}
{
name = ''
When both versionsFile and legacyVersionFiles are provided and the
plugins does not overlap, then returns packages specified in both files
'';
actual = lib.packagesFromVersionsFile {
versionsFile = builtins.toFile ".tool-versions" ''
terraform 1.6.3
'';
legacyVersionFiles = {
python = builtins.toFile ".python-version" ''
3.12.0
'';
};
plugins = {
python = {
hasVersion = _: true;
packageFromVersion = { version, ... }: version;
};
terraform = {
hasVersion = _: true;
packageFromVersion = { version, ... }: version;
};
};
};
expected = { python = "3.12.0"; terraform = "1.6.3"; };
}
{
name = ''
When both versionsFile and legacyVersionFiles are provided and the
plugins overlap, then the version of the tool coming from the legacy file
takes more precedence
'';
actual = lib.packagesFromVersionsFile {
versionsFile = builtins.toFile ".tool-versions" ''
python 2.7.6
terraform 1.6.3
'';
legacyVersionFiles = {
python = builtins.toFile ".python-version" ''
3.12.0
'';
};
plugins = {
python = {
hasVersion = _: true;
packageFromVersion = { version, ... }: version;
};
terraform = {
hasVersion = _: true;
packageFromVersion = { version, ... }: version;
};
};
};
expected = { python = "3.12.0"; terraform = "1.6.3"; };
}
]