mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
migrate discard staged changes test
This commit is contained in:
parent
ae07cf5506
commit
f2d0f362d4
36 changed files with 76 additions and 71 deletions
|
@ -24,3 +24,26 @@ func (self *FileSystem) PathNotPresent(path string) {
|
||||||
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Asserts that the file at the given path has the given content
|
||||||
|
func (self *FileSystem) FileContainsContent(path string, matcher *matcher) {
|
||||||
|
self.assertWithRetries(func() (bool, string) {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return false, fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := os.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Sprintf("Expected error when reading file content at path '%s': %s", path, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
strOutput := string(output)
|
||||||
|
|
||||||
|
if ok, errMsg := matcher.context("").test(strOutput); !ok {
|
||||||
|
return false, fmt.Sprintf("Unexpected content in file %s: %s", path, errMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, ""
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
52
pkg/integration/tests/file/discard_staged_changes.go
Normal file
52
pkg/integration/tests/file/discard_staged_changes.go
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
package file
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var DiscardStagedChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Discarding staged changes",
|
||||||
|
ExtraCmdArgs: "",
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
|
},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.CreateFileAndAdd("fileToRemove", "original content")
|
||||||
|
shell.CreateFileAndAdd("file2", "original content")
|
||||||
|
shell.Commit("first commit")
|
||||||
|
|
||||||
|
shell.CreateFile("file3", "original content")
|
||||||
|
shell.UpdateFile("fileToRemove", "new content")
|
||||||
|
shell.UpdateFile("file2", "new content")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Files().
|
||||||
|
IsFocused().
|
||||||
|
Lines(
|
||||||
|
Contains(` M file2`).IsSelected(),
|
||||||
|
Contains(` M fileToRemove`),
|
||||||
|
Contains(`?? file3`),
|
||||||
|
).
|
||||||
|
SelectNextItem().
|
||||||
|
PressPrimaryAction().
|
||||||
|
Lines(
|
||||||
|
Contains(` M file2`),
|
||||||
|
Contains(`M fileToRemove`).IsSelected(),
|
||||||
|
Contains(`?? file3`),
|
||||||
|
).
|
||||||
|
Press(keys.Files.ViewResetOptions)
|
||||||
|
|
||||||
|
t.ExpectPopup().Menu().Title(Equals("")).Select(Contains("discard staged changes")).Confirm()
|
||||||
|
|
||||||
|
// staged file has been removed
|
||||||
|
t.Views().Files().
|
||||||
|
Lines(
|
||||||
|
Contains(` M file2`),
|
||||||
|
Contains(`?? file3`).IsSelected(),
|
||||||
|
)
|
||||||
|
|
||||||
|
// the file should have the same content that it originally had, given that that was committed already
|
||||||
|
t.FileSystem().FileContainsContent("fileToRemove", Equals("original content"))
|
||||||
|
},
|
||||||
|
})
|
|
@ -53,6 +53,7 @@ var tests = []*components.IntegrationTest{
|
||||||
custom_commands.MultiplePrompts,
|
custom_commands.MultiplePrompts,
|
||||||
file.DirWithUntrackedFile,
|
file.DirWithUntrackedFile,
|
||||||
file.DiscardChanges,
|
file.DiscardChanges,
|
||||||
|
file.DiscardStagedChanges,
|
||||||
interactive_rebase.AmendMerge,
|
interactive_rebase.AmendMerge,
|
||||||
interactive_rebase.One,
|
interactive_rebase.One,
|
||||||
stash.Rename,
|
stash.Rename,
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
file2
|
|
|
@ -1 +0,0 @@
|
||||||
ref: refs/heads/master
|
|
|
@ -1 +0,0 @@
|
||||||
02f629e46dbaa03b58196cced3df07b02c0daf22
|
|
|
@ -1,8 +0,0 @@
|
||||||
[core]
|
|
||||||
repositoryformatversion = 0
|
|
||||||
filemode = true
|
|
||||||
bare = false
|
|
||||||
logallrefupdates = true
|
|
||||||
[user]
|
|
||||||
email = CI@example.com
|
|
||||||
name = CI
|
|
|
@ -1 +0,0 @@
|
||||||
Unnamed repository; edit this file 'description' to name the repository.
|
|
Binary file not shown.
|
@ -1,6 +0,0 @@
|
||||||
# git ls-files --others --exclude-from=.git/info/exclude
|
|
||||||
# Lines that start with '#' are comments.
|
|
||||||
# For a project mostly in C, the following would be a good set of
|
|
||||||
# exclude patterns (uncomment them if you want to use them):
|
|
||||||
# *.[oa]
|
|
||||||
# *~
|
|
|
@ -1,5 +0,0 @@
|
||||||
0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI <CI@example.com> 1652009263 +0200 commit (initial): file0
|
|
||||||
22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI <CI@example.com> 1652009263 +0200 commit: file1
|
|
||||||
9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009263 +0200 commit: file2
|
|
||||||
02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009266 +0200 reset: moving to HEAD
|
|
||||||
02f629e46dbaa03b58196cced3df07b02c0daf22 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009266 +0200 reset: moving to HEAD
|
|
|
@ -1,3 +0,0 @@
|
||||||
0000000000000000000000000000000000000000 22f24c5fcc97c1ff826ecb66b60bdc01937f6052 CI <CI@example.com> 1652009263 +0200 commit (initial): file0
|
|
||||||
22f24c5fcc97c1ff826ecb66b60bdc01937f6052 9e7ff93a5c67a0ef098e9e436961746f333edf98 CI <CI@example.com> 1652009263 +0200 commit: file1
|
|
||||||
9e7ff93a5c67a0ef098e9e436961746f333edf98 02f629e46dbaa03b58196cced3df07b02c0daf22 CI <CI@example.com> 1652009263 +0200 commit: file2
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
x<01><>Á
|
|
||||||
Â0=ç+ö.È&ݦ.ˆ=õ3’æ
)%‚Ÿo>ÁÛ0ÌZKÙY‘K;²à§¨ª)Úqò!Y€ï1KfSv
|
|
||||||
Qg§½ëIóB<C3B3>yyáʱã¶Öò$ëGǬÎtåN¦Û>iø37yÛÁæÙ2+à
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +0,0 @@
|
||||||
x+)JMU°΄d040031QHΛΜI5`°±Ί²ΰ<C2B2>Φ¶wΑ‡ήw.½ωhοTΣ[H
|
|
||||||
<19>Ώe“ς"Η¨ΰSς,αΚgu"<22><>YH
|
|
||||||
<EFBFBD>$x~5(ν;χrΥΆπ<CE86>ώ–WΪσ-ΤΠ–+^
|
|
|
@ -1,2 +0,0 @@
|
||||||
x<01>ŽÁ
|
|
||||||
Â0D=ç+ö.Èv›n<õ3²É¦-5‚Ÿo.Þ½
üáŵ”¹uã¡îªÀ,ú˜BNŽÇ˜}O(YF묈ËÁyg3[Øu©€”™¼ZNö2¸ÎsŒšú”q¤ˆí‰È„w}¬;Ü'¸Ü§›~BÙžzŠk¹BÇ!zb†#¶dZÛ¤ªþ97ó’ôë%¼uþYAžŸJæ BP
|
|
|
@ -1,2 +0,0 @@
|
||||||
x<01>ŽA
|
|
||||||
Â0E]çÙ2™$"BW=F2™Á‚µ¥Dðøæî><3E>÷àó¶®K·.ã©"¶A"æÌ¹p)Ø<iåTrÔæ=PÈ<50>‚3{9äÝ-¢bਣIìT¯H•¨ÔÆà²OJÑ”On‡<6E>f{›æ‡|˺¿äÂÛz·Ž"d$oÏ0–tœêò§nty‰3?ÄÇ9Ø
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,2 +0,0 @@
|
||||||
x+)JMU03c040031QHヒフI5`ーアコイ燹ヨカwチ<77>w.ス<><EFBDBD>モ[H
|
|
||||||
矢y<E79FA2>5<EFBFBD>来ミ(桍ァ^-ンW(x9
|
|
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
02f629e46dbaa03b58196cced3df07b02c0daf22
|
|
|
@ -1 +0,0 @@
|
||||||
test0
|
|
|
@ -1 +0,0 @@
|
||||||
test1
|
|
|
@ -1 +0,0 @@
|
||||||
hello there
|
|
|
@ -1 +0,0 @@
|
||||||
hello there
|
|
|
@ -1 +0,0 @@
|
||||||
{"KeyEvents":[{"Timestamp":1175,"Mod":0,"Key":256,"Ch":32},{"Timestamp":1991,"Mod":0,"Key":256,"Ch":68},{"Timestamp":2923,"Mod":0,"Key":256,"Ch":83},{"Timestamp":4453,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":213,"Height":56}]}
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd $1
|
|
||||||
|
|
||||||
git init
|
|
||||||
|
|
||||||
git config user.email "CI@example.com"
|
|
||||||
git config user.name "CI"
|
|
||||||
|
|
||||||
echo test0 > file0
|
|
||||||
git add .
|
|
||||||
git commit -am file0
|
|
||||||
|
|
||||||
echo test1 > file1
|
|
||||||
git add .
|
|
||||||
git commit -am file1
|
|
||||||
|
|
||||||
echo test2 > file2
|
|
||||||
git add .
|
|
||||||
git commit -am file2
|
|
||||||
|
|
||||||
echo "hello there" > file1
|
|
||||||
echo "hello there" > file2
|
|
||||||
echo "hello there" > file3
|
|
|
@ -1 +0,0 @@
|
||||||
{ "description": "Discarding staged changes", "speed": 5 }
|
|
Loading…
Add table
Add a link
Reference in a new issue