summaryrefslogtreecommitdiff
path: root/tests/SlackBuilder/LatestVersionCheckSpec.hs
blob: 9abce99a3a9a2b38f729868a5d69656dad43bddf (plain)
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
{- This Source Code Form is subject to the terms of the Mozilla Public License,
   v. 2.0. If a copy of the MPL was not distributed with this file, You can
   obtain one at https://mozilla.org/MPL/2.0/. -}

module SlackBuilder.LatestVersionCheckSpec
    ( spec
    ) where

import SlackBuilder.LatestVersionCheck
import Test.Hspec (Spec, describe, it, shouldBe)

spec :: Spec
spec = do
    describe "stableTagTransform" $ do
        it "excludes tags with +" $
            let given = "v2.6.0+unreleased"
                actual = stableTagTransform given
             in actual `shouldBe` Nothing

        it "recognizes a stable version" $
            let given = "v2.6.0"
                actual = stableTagTransform given
                expected = Just "2.6.0"
             in actual `shouldBe` expected

    describe "match" $ do
        it "matches an exact tag prefixed with v" $ 
            let expected = Just "2.6.0"
                actual = match "(v)2.6.0" "v2.6.0"
             in actual `shouldBe` expected

        it "matches a glob pattern prefixed with v" $ 
            let expected = Just "2.6.0"
                actual = match "(v)*" "v2.6.0"
             in actual `shouldBe` expected

        it "ignores suffix after wildcard" $ 
            let expected = Just "2.6.0"
                actual = match "(v)*(-rc1)" "v2.6.0-rc1"
             in actual `shouldBe` expected