test/integration/test_sup-add.rb (2101B) - raw
1 class TestSupAdd < Minitest::Test
2
3 def setup
4 @path = Dir.mktmpdir
5 end
6
7 def teardown
8 FileUtils.rm_r @path
9 end
10
11 def test_can_add_maildir_source
12 _out, _err = capture_subprocess_io do
13 assert system({"SUP_BASE" => @path}, "bin/sup-add", "maildir:///some/path")
14 end
15
16 generated_sources_yaml = File.read "#{@path}/sources.yaml"
17 assert_equal <<EOS, generated_sources_yaml
18 ---
19 - !<tag:supmua.org,2006-10-01/Redwood/Maildir>
20 uri: maildir:///some/path
21 usual: true
22 archived: false
23 sync_back: true
24 id: 1
25 labels: []
26 EOS
27 end
28
29 ## https://github.com/sup-heliotrope/sup/issues/577
30 ## https://github.com/sup-heliotrope/sup/issues/516
31 def test_fixes_old_tag_uri_syntax
32 File.write "#{@path}/sources.yaml", <<EOS
33 ---
34 - !supmua.org,2006-10-01/Redwood/Maildir
35 uri: maildir:/some/path
36 usual: true
37 archived: false
38 sync_back: true
39 id: 1
40 labels: []
41 - !supmua.org,2006-10-01/Redwood/SentLoader {}
42 EOS
43 _out, _err = capture_subprocess_io do
44 assert system({"SUP_BASE" => @path}, "bin/sup-add", "maildir:///other/path")
45 end
46
47 generated_sources_yaml = File.read "#{@path}/sources.yaml"
48 assert_equal <<EOS, generated_sources_yaml
49 ---
50 - !<tag:supmua.org,2006-10-01/Redwood/Maildir>
51 uri: maildir:/some/path
52 usual: true
53 archived: false
54 sync_back: true
55 id: 1
56 labels: []
57 - !<tag:supmua.org,2006-10-01/Redwood/Maildir>
58 uri: maildir:///other/path
59 usual: true
60 archived: false
61 sync_back: true
62 id: 2
63 labels: []
64 - !<tag:supmua.org,2006-10-01/Redwood/SentLoader> {}
65 EOS
66 end
67
68 ## https://github.com/sup-heliotrope/sup/issues/545
69 def test_source_with_invalid_uri_chars_in_path
70 _out, _err = capture_subprocess_io do
71 assert system({"SUP_BASE" => @path}, "bin/sup-add", "maildir:~/.mail/gmail/[Gmail]/.All Mail/")
72 end
73
74 generated_sources_yaml = File.read "#{@path}/sources.yaml"
75 assert_equal <<EOS, generated_sources_yaml
76 ---
77 - !<tag:supmua.org,2006-10-01/Redwood/Maildir>
78 uri: maildir:~/.mail/gmail/[Gmail]/.All Mail/
79 usual: true
80 archived: false
81 sync_back: true
82 id: 1
83 labels: []
84 EOS
85 end
86
87 end