module Eclogues.Scheduling.RunSpec where

import Eclogues.Prelude
import Eclogues.Scheduling.Run (containerDownloadURI)
import TestUtils (echoContainer, exampleBase)

import Eclogues.API (parseAbsoluteURI, uriPath)

import Test.Hspec

spec :: Spec
spec = describe "containerDownloadURI" . it "produces the expected URI" $ do
    -- no slash terminating exampleBase
    containerDownloadURI exampleBase echoContainer `shouldBe` expected
    -- with slash
    containerDownloadURI (exampleBase & uriPath .~ "/") echoContainer `shouldBe` expected
  where
    expected = fromMaybe (error "bad expected URI") $ parseAbsoluteURI "http://example.com/containers/echo"
