1 # pylint: disable=redefined-outer-name
2 from cola
.models
.stash
import StashModel
5 from .helper
import app_context
8 # These assertions make pylint happy. It considers them unused imports otherwise.
9 assert app_context
is not None
12 def test_stash_info_for_message_without_slash(app_context
):
14 helper
.write_file('A', 'change')
15 helper
.run_git('stash', 'save', 'some message')
16 assert StashModel(app_context
).stash_info()[0] == [
17 r
'stash@{0}: On main: some message'
21 def test_stash_info_for_message_with_slash(app_context
):
23 helper
.write_file('A', 'change')
24 helper
.run_git('stash', 'save', 'some message/something')
25 model
= StashModel(app_context
)
26 stash_details
= model
.stash_info()[0]
27 assert stash_details
== [r
'stash@{0}: On main: some message/something']
30 def test_stash_info_on_branch_with_slash(app_context
):
32 helper
.run_git('checkout', '-b', 'feature/a')
33 helper
.write_file('A', 'change')
34 helper
.run_git('stash', 'save', 'some message')
36 model
= StashModel(app_context
)
37 stash_info
= model
.stash_info()
39 stash_details
= stash_info
[0][0]
40 assert stash_details
in (
41 'stash@{0}: On feature/a: some message',
42 # Some versions of Git do not report the full branch name
43 'stash@{0}: On a: some message',
46 stash_rev
= stash_info
[1][0]
47 assert stash_rev
== r
'stash@{0}'
49 stash_message
= stash_info
[3][0]
50 assert stash_message
in (
51 'On feature/a: some message',