on master help sign in
add selftest for ob thunk update --branch
commit1d2ea599ebdaa98aacc5014c943f19c5d316eb95 authorhsloan <ishaqsloan@gmail.com> dateFri 30 Nov 2018, 21:51 (8 years ago) parentd0e6b39
1 file changed+17
lib/selftest/src/Obelisk/SelfTest.hs+17
lib/selftest/src/Obelisk/SelfTest.hs+17
@@ -213,6 +213,23 @@ main = do
213213 void $ unpack
214214 testThunkPack (dir </> thunk)
215215
216+ describe "ob thunk update --branch" $ parallel $ do
217+ it "can change a thunk to the latest version of a desired branch" $ withTmp $ \dir -> do
218+ let branch1 = "master"
219+ branch2 = "develop"
220+ run_ "git" ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", branch1]
221+ run_ "ob" ["thunk" , "pack", toTextIgnore dir]
222+ run_ "ob" ["thunk", "update", toTextIgnore dir, "--branch", branch2]
223+
224+ it "doesn't create anything when given an invalid branch" $ withTmp $ \dir -> do
225+ let checkDir dir' = liftIO $ getDirectoryContents $ T.unpack $ toTextIgnore dir'
226+ run_ "git" ["clone", "https://github.com/reflex-frp/reflex.git", toTextIgnore dir, "--branch", "master"]
227+ run_ "ob" ["thunk" , "pack", toTextIgnore dir]
228+ startingContents <- checkDir dir
229+ void $ errExit False $ run "ob" ["thunk", "update", toTextIgnore dir, "--branch", "dumble-palooza"]
230+ checkDir dir >>= liftIO . assertEqual "" startingContents
231+
232+
216233-- | Run `ob run` in the given directory (maximum of one level deep)
217234testObRunInDir :: Socket.PortNumber -> Socket.PortNumber -> Maybe Shelly.FilePath -> HTTP.Manager -> Sh ()
218235testObRunInDir p0 p1 mdir httpManager = handle_sh (\case ExitSuccess -> pure (); e -> throw e) $ do