mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-17 13:27:30 +03:00
Add test asserting that local changes are wiped out when there's changes on the remote
This commit is contained in:
parent
76a0c295a2
commit
5809a9f321
@ -11,7 +11,7 @@ import Data.String.Here.Interpolated (i)
|
||||
import qualified Data.Text as Text
|
||||
import EasyTest
|
||||
import Shellmet ()
|
||||
import System.Directory (removeDirectoryRecursive)
|
||||
import System.Directory (removeDirectoryRecursive, doesFileExist)
|
||||
import System.FilePath ((</>))
|
||||
import qualified System.IO.Temp as Temp
|
||||
import qualified Unison.Codebase as Codebase
|
||||
@ -40,6 +40,7 @@ test = scope "gitsync22" . tests $
|
||||
fastForwardPush :
|
||||
nonFastForwardPush :
|
||||
localStatePersistence :
|
||||
localStateUpdate :
|
||||
destroyedRemote :
|
||||
flip map [(Ucm.CodebaseFormat2, "sc")]
|
||||
\(fmt, name) -> scope name $ tests [
|
||||
@ -671,6 +672,42 @@ localStatePersistence = scope "local-state-persistence" do
|
||||
txt <- io $ Text.readFile someFilePath
|
||||
expectEqual someText txt
|
||||
|
||||
-- | Any untracked files in the cache directory should be wiped out if there's a change
|
||||
-- on the remote.
|
||||
localStateUpdate :: Test ()
|
||||
localStateUpdate = scope "local-state-update" do
|
||||
repo <- io initGitRepo
|
||||
cachedRepoDir <- io $ gitCacheDir (Text.pack repo)
|
||||
-- Create some local state in the cached git repo.
|
||||
let someFilePath = cachedRepoDir </> "myfile.txt"
|
||||
let someText = "SOME TEXT"
|
||||
io $ do
|
||||
codebase <- Ucm.initCodebase Ucm.CodebaseFormat2
|
||||
-- Push some state the remote codebase
|
||||
-- Then pull to ensure we have a non-empty local git repo.
|
||||
void $ Ucm.runTranscript codebase [i|
|
||||
```ucm
|
||||
.lib> alias.type ##Nat Nat
|
||||
.lib> push.create ${repo}
|
||||
.lib> pull ${repo}
|
||||
```
|
||||
|]
|
||||
-- Write a file to our local git cache to represent some changes we may have made to our
|
||||
-- codebase, e.g. a migration.
|
||||
Text.writeFile someFilePath someText
|
||||
-- Push the new change, then pull the new remote.
|
||||
void $ Ucm.runTranscript codebase [i|
|
||||
```ucm
|
||||
.lib> alias.type ##Nat Nat2
|
||||
.lib> push ${repo}
|
||||
.lib> pull ${repo}
|
||||
```
|
||||
|]
|
||||
-- We expect the state in the cached git repo to be wiped out, since there's a new commit on
|
||||
-- the remote.
|
||||
fileExists <- io $ doesFileExist someFilePath
|
||||
expect (not fileExists)
|
||||
|
||||
nonFastForwardPush :: Test ()
|
||||
nonFastForwardPush = scope "non-fastforward-push" do
|
||||
io do
|
||||
|
Loading…
Reference in New Issue
Block a user