@@ -7,6 +7,7 @@ import Data.Map as Map
77import Effect.Now as Now
88import Registry.Version as Version
99import Spago.Command.Init as Init
10+ import Spago.Core.Config (Dependencies (..), Config )
1011import Spago.Core.Config as Config
1112import Spago.FS as FS
1213import Spago.Log (LogVerbosity (..))
@@ -17,6 +18,7 @@ import Test.Spec (Spec)
1718import Test.Spec as Spec
1819import Test.Spec.Assertions as Assert
1920import Test.Spec.Assertions as Assertions
21+ import Test.Spec.Assertions.String (shouldContain )
2022
2123spec :: Spec Unit
2224spec = Spec .around withTempDir do
@@ -61,6 +63,32 @@ spec = Spec.around withTempDir do
6163 spago [ " install" , " foo-foo-foo" , " bar-bar-bar" , " effcet" , " arrys" ] >>= shouldBeFailureErr (fixture " missing-dependencies.txt" )
6264 checkFixture (testCwd </> " spago.yaml" ) (fixture " spago-install-failure.yaml" )
6365
66+ Spec .it " warns when specified dependency versions do not exist" \{ spago, fixture, testCwd } -> do
67+ spago [ " init" , " --package-set" , " 29.3.0" ] >>= shouldBeSuccess
68+
69+ FS .writeYamlFile Config .configCodec (testCwd </> " spago.yaml" )
70+ $ insertConfigDependencies
71+ ( Init .defaultConfig
72+ { name: mkPackageName " aaa"
73+ , withWorkspace: Just { setVersion: Just $ unsafeFromRight $ Version .parse " 0.0.1" }
74+ , testModuleName: " Test.Main"
75+ }
76+ )
77+ ( Dependencies $ Map .fromFoldable
78+ [ Tuple (mkPackageName " prelude" ) (Just $ mkRange " >=6.0.0 <7.0.0" )
79+ , Tuple (mkPackageName " lists" ) (Just $ mkRange " >=1000.0.0 <1000.0.1" )
80+ ]
81+ )
82+ ( Dependencies $ Map .fromFoldable
83+ [ Tuple (mkPackageName " spec" ) (Just $ mkRange " >=7.0.0 <8.0.0" )
84+ , Tuple (mkPackageName " maybe" ) (Just $ mkRange " >=1000.0.0 <1000.0.1" )
85+ ]
86+ )
87+
88+ warning <- FS .readTextFileSync $ fixture " missing-versions.txt"
89+ outputs <- spago [ " install" ]
90+ either _.stderr _.stderr outputs `shouldContain` warning
91+
6492 Spec .it " does not allow circular dependencies" \{ spago, fixture, testCwd } -> do
6593 spago [ " init" ] >>= shouldBeSuccess
6694 let
@@ -234,6 +262,19 @@ spec = Spec.around withTempDir do
234262 -- Check that the lockfile is back to the original
235263 checkFixture (testCwd </> " spago.lock" ) (fixture " spago.lock" )
236264
265+
266+ insertConfigDependencies :: Config -> Dependencies -> Dependencies -> Config
267+ insertConfigDependencies config core test =
268+ ( config
269+ { package = config.package # map
270+ ( \package' -> package'
271+ { dependencies = core
272+ , test = package'.test # map ((_ { dependencies = test }))
273+ }
274+ )
275+ }
276+ )
277+
237278writeConfigWithEither :: RootPath -> Aff Unit
238279writeConfigWithEither root = do
239280 -- The commit for `either` is for the `v6.1.0` release
0 commit comments