/
test_cdstk.rb
108 lines (85 loc) · 2.9 KB
/
test_cdstk.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# -*- coding: utf-8 -*-
#
# @file
# @brief
# @author ongaeshi
# @date 2011/02/20
require 'rubygems'
require 'groonga'
require 'test_helper'
require 'file_test_utils'
require 'milkode/cdstk/cdstk'
require 'stringio'
class TestCdstk < Test::Unit::TestCase
include Milkode
include FileTestUtils
# メッセージを出す時はここをコメントアウト
def dbputs(msg)
# puts msg
end
private :dbputs
def test_basic
io = StringIO.new
begin
obj = Cdstk.new(io)
io.puts('--- init ---')
obj.init({})
io.puts('--- add ---')
obj.add(['../../lib/milkode/findgrep', '../../lib/milkode/common'], {})
obj.add(['../../lib/milkode/findgrep'], {})
obj.add(['../data/abc.zip'], {})
obj.add(['../data/nodir_abc.zip'], {})
obj.add(['../data/nodir_abc_xpi.xpi'], {})
obj.add(['http://ongaeshi.me/test_data/http_nodir_abc.zip'], {})
obj.add(['git://github.com/ongaeshi/duplicate-thing.git'], {})
# obj.add(['git@github.com:ongaeshi/kodeworld.git'], {})
assert_raise(OpenURI::HTTPError) { obj.add(['http://ongaeshi.me/test_data/not_found.zip'], {}) }
obj.add(['../data/no_auto_ignore'], {:no_auto_ignore => true})
obj.add(['git://github.com/ongaeshi/duplicate-thing.git'], {:protocol => 'git', :name => 'ddd'})
FileUtils.touch('last1.txt')
obj.add(['last1.txt'], {})
FileUtils.touch('atodekesu.txt')
obj.add(['atodekesu.txt'], {})
FileUtils.rm('atodekesu.txt')
io.puts('--- add notfound ---')
obj.add(['notfound.html'], {})
io.puts('--- update_all ---')
FileUtils.touch('packages/zip/abc/c.txt')
FileUtils.touch('packages/zip/abc/d.txt')
obj.update_all({})
io.puts('--- update --all ---')
FileUtils.touch('packages/zip/abc/e.txt')
obj.update([], {:all => true})
io.puts('--- update in package dir ---')
Dir.chdir('packages/zip/abc') do
# setdbコマンドが無いので上手く動かせない
# obj.update([], {})
end
# Database.instance.yaml_reload
io.puts('--- remove ---')
obj.remove(['findgrep'], {:force => true})
obj.remove([], {:force => true})
obj.remove(['abc', 'nodir_abc'], {:force => true})
io.puts('--- list ---')
obj.list([], {:verbose => true})
obj.list(['com'], {:verbose => false})
io.puts('--- cleanup ---')
obj.cleanup({:force=>true})
io.puts('--- rebuild ---')
obj.rebuild([], {:all => true})
io.puts('--- ignore ---')
obj.ignore(['dir*', '*snip*'], {:package => "common"})
obj.ignore([], {:package => "common", :test => true})
io.puts('--- remove ---')
obj.remove(['findgrep', 'common'], {:force => true})
io.puts('--- dump ---')
obj.dump
ensure
dbputs io.string
end
end
def teardown
teardown_custom(true)
# teardown_custom(false)
end
end