11import datetime as dt
22
33import pytest
4+ import pathlib
45from rattler import Version
56
6- from minimum_versions import Policy , Release , Spec
7+ from minimum_versions import Policy , Release , Spec , _main
78
89
910@pytest .mark .parametrize (
@@ -27,6 +28,25 @@ def test_spec_parse(text, expected_spec, expected_name, expected_warnings):
2728 assert actual_warnings == expected_warnings
2829
2930
31+ def test_error_missing_version_or_exclude ():
32+
33+
34+ msg = (
35+ "No minimum version found for 'package_no_version_not_in_exclude' in"
36+ " 'failing-env2'. Either add a version or add to the list of excluded packages"
37+ " in the policy file."
38+ )
39+
40+ with open ("policy.yaml" ) as policy :
41+
42+ environment_paths = [pathlib .Path ("envs/failing-env2.yaml" )]
43+
44+ with pytest .raises (ValueError , match = msg ):
45+ _main (dt .date (2023 , 12 , 12 ), policy , environment_paths = environment_paths )
46+
47+
48+
49+
3050@pytest .mark .parametrize (
3151 ["package_name" , "policy" , "today" , "expected" ],
3252 (
@@ -72,3 +92,5 @@ def test_policy_minimum_version(package_name, policy, today, expected):
7292 actual = policy .minimum_version (today , package_name , releases [package_name ])
7393
7494 assert actual == expected
95+
96+
0 commit comments