eternity 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +18 -0
- data/eternity.gemspec +39 -0
- data/lib/eternity.rb +64 -0
- data/lib/eternity/blob.rb +94 -0
- data/lib/eternity/branch.rb +34 -0
- data/lib/eternity/collection_index.rb +47 -0
- data/lib/eternity/collection_tracker.rb +55 -0
- data/lib/eternity/commit.rb +151 -0
- data/lib/eternity/conflict_resolver.rb +40 -0
- data/lib/eternity/delta.rb +45 -0
- data/lib/eternity/index.rb +29 -0
- data/lib/eternity/log.rb +22 -0
- data/lib/eternity/object_tracker.rb +57 -0
- data/lib/eternity/patch.rb +129 -0
- data/lib/eternity/repository.rb +235 -0
- data/lib/eternity/track_flatter.rb +57 -0
- data/lib/eternity/tracker.rb +38 -0
- data/lib/eternity/version.rb +3 -0
- data/spec/blob_spec.rb +83 -0
- data/spec/branch_spec.rb +71 -0
- data/spec/checkout_spec.rb +110 -0
- data/spec/commit_spec.rb +104 -0
- data/spec/coverage_helper.rb +8 -0
- data/spec/delta_spec.rb +110 -0
- data/spec/index_spec.rb +76 -0
- data/spec/locking_spec.rb +122 -0
- data/spec/log_spec.rb +57 -0
- data/spec/minitest_helper.rb +79 -0
- data/spec/patch_spec.rb +213 -0
- data/spec/pull_spec.rb +292 -0
- data/spec/push_spec.rb +72 -0
- data/spec/repository_spec.rb +73 -0
- data/spec/revert_spec.rb +40 -0
- data/spec/tracker_spec.rb +143 -0
- metadata +270 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe Repository, 'Checkout' do
|
4
|
+
|
5
|
+
let(:repository) { Repository.new :test }
|
6
|
+
|
7
|
+
describe 'Branch' do
|
8
|
+
|
9
|
+
it 'Local' do
|
10
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
11
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
12
|
+
|
13
|
+
repository.branch :test_branch
|
14
|
+
|
15
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
16
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
17
|
+
|
18
|
+
repository.current_branch.must_equal 'master'
|
19
|
+
repository.current_commit.must_equal commit_2
|
20
|
+
|
21
|
+
delta = repository.checkout branch: :test_branch
|
22
|
+
|
23
|
+
delta.must_equal 'countries' => {'UY' => {'action' => 'delete'}}
|
24
|
+
|
25
|
+
repository.current_branch.must_equal 'test_branch'
|
26
|
+
repository.current_commit.must_equal commit_1
|
27
|
+
|
28
|
+
repository.branches.to_h.must_equal 'master' => commit_2.id,
|
29
|
+
'test_branch' => commit_1.id
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'Remote' do
|
33
|
+
other_repository = Repository.new :other
|
34
|
+
other_repository[:countries].insert 'AR', name: 'Argentina'
|
35
|
+
commit = other_repository.commit author: 'User', message: 'Commit message'
|
36
|
+
|
37
|
+
Branch[:test_branch] = commit.id
|
38
|
+
|
39
|
+
delta = repository.checkout branch: :test_branch
|
40
|
+
|
41
|
+
delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
42
|
+
|
43
|
+
repository.current_branch.must_equal 'test_branch'
|
44
|
+
repository.current_commit.must_equal commit
|
45
|
+
repository.branches.to_h.must_equal 'test_branch' => commit.id
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'Invalid' do
|
49
|
+
error = proc { repository.checkout branch: :test_branch }.must_raise RuntimeError
|
50
|
+
error.message.must_equal 'Invalid branch test_branch'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'Commit' do
|
56
|
+
|
57
|
+
it 'Valid' do
|
58
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
59
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
60
|
+
|
61
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
62
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
63
|
+
|
64
|
+
repository.current_branch.must_equal 'master'
|
65
|
+
repository.current_commit.must_equal commit_2
|
66
|
+
repository.branches.to_h.must_equal 'master' => commit_2.id
|
67
|
+
|
68
|
+
delta = repository.checkout commit: commit_1.id
|
69
|
+
|
70
|
+
delta.must_equal 'countries' => {'UY' => {'action' => 'delete'}}
|
71
|
+
|
72
|
+
repository.current_branch.must_equal 'master'
|
73
|
+
repository.current_commit.must_equal commit_1
|
74
|
+
repository.branches.to_h.must_equal 'master' => commit_1.id
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'Invalid' do
|
78
|
+
error = proc { repository.checkout commit: '123456789' }.must_raise RuntimeError
|
79
|
+
error.message.must_equal 'Invalid commit 123456789'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'Null' do
|
83
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
84
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
85
|
+
|
86
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
87
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
88
|
+
|
89
|
+
delta = repository.checkout commit: nil
|
90
|
+
|
91
|
+
delta.must_equal 'countries' => {
|
92
|
+
'AR' => {'action' => 'delete'},
|
93
|
+
'UY' => {'action' => 'delete'}
|
94
|
+
}
|
95
|
+
|
96
|
+
repository.current_branch.must_equal 'master'
|
97
|
+
repository.current_commit.must_be_nil
|
98
|
+
repository.branches.to_h.must_be_empty
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'With uncommitted changes' do
|
104
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
105
|
+
|
106
|
+
error = proc { repository.checkout branch: :test_branch }.must_raise RuntimeError
|
107
|
+
error.message.must_equal "Can't checkout with uncommitted changes"
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
data/spec/commit_spec.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe Repository, 'Commit' do
|
4
|
+
|
5
|
+
let(:repository) { Repository.new :test }
|
6
|
+
|
7
|
+
it 'First' do
|
8
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
9
|
+
|
10
|
+
repository.must_be :changes?
|
11
|
+
repository.changes_count.must_equal 1
|
12
|
+
repository.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
13
|
+
|
14
|
+
commit = repository.commit author: 'User', message: 'Commit message'
|
15
|
+
|
16
|
+
repository.wont_be :changes?
|
17
|
+
repository.changes_count.must_equal 0
|
18
|
+
repository.delta.must_be_empty
|
19
|
+
|
20
|
+
repository.current_commit.tap do |current_commit|
|
21
|
+
current_commit.must_equal commit
|
22
|
+
current_commit.time.must_be_instance_of Time
|
23
|
+
current_commit.author.must_equal 'User'
|
24
|
+
current_commit.message.must_equal 'Commit message'
|
25
|
+
current_commit.parent_ids.must_equal [nil]
|
26
|
+
current_commit.must_be :first?
|
27
|
+
current_commit.wont_be :merge?
|
28
|
+
current_commit.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
29
|
+
current_commit.must_equal_index 'countries' => {'AR' => digest(name: 'Argentina')}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'Sequence' do
|
34
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
35
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
36
|
+
|
37
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
38
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
39
|
+
|
40
|
+
repository.current_commit.tap do |current_commit|
|
41
|
+
current_commit.must_equal commit_2
|
42
|
+
current_commit.time.must_be_instance_of Time
|
43
|
+
current_commit.author.must_equal 'User'
|
44
|
+
current_commit.message.must_equal 'Commit 2'
|
45
|
+
current_commit.parent_ids.must_equal [commit_1.id]
|
46
|
+
current_commit.wont_be :first?
|
47
|
+
current_commit.wont_be :merge?
|
48
|
+
current_commit.delta.must_equal 'countries' => {'UY' => {'action' => 'insert', 'data' => {'name' => 'Uruguay'}}}
|
49
|
+
current_commit.must_equal_index 'countries' => {
|
50
|
+
'AR' => digest(name: 'Argentina'),
|
51
|
+
'UY' => digest(name: 'Uruguay')
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'No changes' do
|
57
|
+
error = proc { repository.commit author: 'User', message: 'Commit message' }.must_raise RuntimeError
|
58
|
+
error.message.must_equal 'Nothing to commit'
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'Empty author' do
|
62
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
63
|
+
error = proc { repository.commit author: '', message: 'Commit message' }.must_raise RuntimeError
|
64
|
+
error.message.must_equal 'Author must be present'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'Empty message' do
|
68
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
69
|
+
error = proc { repository.commit author: 'User', message: '' }.must_raise RuntimeError
|
70
|
+
error.message.must_equal 'Message must be present'
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'With index' do
|
74
|
+
|
75
|
+
def assert_transeint_index
|
76
|
+
redis.call('KEYS', Eternity.keyspace[:index]['*']).must_be_empty
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'Transient' do
|
80
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
81
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
82
|
+
commit = repository.commit author: 'User', message: 'Commit 1'
|
83
|
+
|
84
|
+
commit.with_index { |i| i[:countries].ids }.must_equal %w(AR UY)
|
85
|
+
|
86
|
+
assert_transeint_index
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'Invalid commit' do
|
90
|
+
commit = Commit.new 'invalid'
|
91
|
+
proc { commit.with_index { fail 'Invalid commit' } }.must_raise RuntimeError
|
92
|
+
assert_transeint_index
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'Invalid block' do
|
96
|
+
commit = Commit.new nil
|
97
|
+
error = proc { commit.with_index { raise 'Test error' } }.must_raise RuntimeError
|
98
|
+
error.message.must_equal 'Test error'
|
99
|
+
assert_transeint_index
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
data/spec/delta_spec.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe Repository, 'Pull' do
|
4
|
+
|
5
|
+
let(:repo_1) { Repository.new :test_1 }
|
6
|
+
let(:repo_2) { Repository.new :test_2 }
|
7
|
+
let(:repo_3) { Repository.new :test_3 }
|
8
|
+
|
9
|
+
it 'test' do
|
10
|
+
repo_1[:countries].insert 'AR', name: 'Argentina'
|
11
|
+
commit_1 = repo_1.commit author: 'User 1', message: 'Commit 1'
|
12
|
+
repo_1.push
|
13
|
+
|
14
|
+
repo_2.pull
|
15
|
+
repo_3.pull
|
16
|
+
|
17
|
+
repo_2[:countries].insert 'BR', name: 'Brasil'
|
18
|
+
commit_2 = repo_2.commit author: 'User 2', message: 'Commit 2'
|
19
|
+
|
20
|
+
repo_2[:countries].update 'AR', name: 'Argentina', code: 54, capital: '...'
|
21
|
+
commit_3 = repo_2.commit author: 'User 2', message: 'Commit 3'
|
22
|
+
|
23
|
+
repo_1[:countries].update 'AR', name: 'Argentina', capital: 'CABA'
|
24
|
+
commit_4 = repo_1.commit author: 'User 1', message: 'Commit 4'
|
25
|
+
|
26
|
+
repo_1[:countries].insert 'CL', name: 'Chile'
|
27
|
+
commit_5 = repo_1.commit author: 'User 1', message: 'Commit 5'
|
28
|
+
|
29
|
+
repo_1.push
|
30
|
+
|
31
|
+
delta = repo_2.pull
|
32
|
+
commit_6 = repo_2.current_commit # Merge
|
33
|
+
|
34
|
+
delta.must_equal 'countries' => {
|
35
|
+
'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina', 'code' => 54, 'capital' => 'CABA'}},
|
36
|
+
'CL' => {'action' => 'insert', 'data' => {'name' => 'Chile'}}
|
37
|
+
}
|
38
|
+
|
39
|
+
commit_6.must_equal_index 'countries' => {
|
40
|
+
'AR' => digest(name: 'Argentina', code: 54, capital: 'CABA'),
|
41
|
+
'BR' => digest(name: 'Brasil'),
|
42
|
+
'CL' => digest(name: 'Chile')
|
43
|
+
}
|
44
|
+
|
45
|
+
repo_2.push
|
46
|
+
|
47
|
+
delta = repo_1.pull
|
48
|
+
|
49
|
+
repo_1.current_commit.must_equal commit_6
|
50
|
+
|
51
|
+
delta.must_equal 'countries' => {
|
52
|
+
'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina', 'code' => 54, 'capital' => 'CABA'}},
|
53
|
+
'BR' => {'action' => 'insert', 'data' => {'name' => 'Brasil'}},
|
54
|
+
'CL' => {'action' => 'update', 'data' => {'name' => 'Chile'}}
|
55
|
+
}
|
56
|
+
|
57
|
+
repo_2[:countries].delete 'CL'
|
58
|
+
repo_2[:countries].insert 'PY', name: 'Paraguay'
|
59
|
+
commit_7 = repo_2.commit author: 'User 2', message: 'Commit 7'
|
60
|
+
|
61
|
+
repo_1[:countries].insert 'CO', name: 'Colombia'
|
62
|
+
commit_8 = repo_1.commit author: 'User 1', message: 'Commit 8'
|
63
|
+
|
64
|
+
repo_1.push
|
65
|
+
|
66
|
+
delta = repo_2.pull
|
67
|
+
commit_9 = repo_2.current_commit # Merge
|
68
|
+
|
69
|
+
delta.must_equal 'countries' => {
|
70
|
+
'CO' => {'action' => 'insert', 'data' => {'name' => 'Colombia'}}
|
71
|
+
}
|
72
|
+
|
73
|
+
commit_9.must_equal_index 'countries' => {
|
74
|
+
'AR' => digest(name: 'Argentina', code: 54, capital: 'CABA'),
|
75
|
+
'BR' => digest(name: 'Brasil'),
|
76
|
+
'PY' => digest(name: 'Paraguay'),
|
77
|
+
'CO' => digest(name: 'Colombia')
|
78
|
+
}
|
79
|
+
|
80
|
+
repo_2[:countries].delete 'CO'
|
81
|
+
commit_10 = repo_2.commit author: 'User 2', message: 'Commit 10'
|
82
|
+
|
83
|
+
repo_2.push
|
84
|
+
|
85
|
+
delta = repo_1.pull
|
86
|
+
|
87
|
+
repo_1.current_commit.must_equal commit_10
|
88
|
+
|
89
|
+
delta.must_equal 'countries' => {
|
90
|
+
'CL' => {'action' => 'delete'},
|
91
|
+
'PY' => {'action' => 'insert', 'data' => {'name' => 'Paraguay'}},
|
92
|
+
'CO' => {'action' => 'delete'}
|
93
|
+
}
|
94
|
+
|
95
|
+
repo_3[:countries].insert 'UY', name: 'Uruguay'
|
96
|
+
commit_11 = repo_3.commit author: 'User 3', message: 'Commit 11'
|
97
|
+
|
98
|
+
delta = repo_3.checkout commit: commit_10.id
|
99
|
+
|
100
|
+
repo_3.current_commit.must_equal commit_10
|
101
|
+
|
102
|
+
delta.must_equal 'countries' => {
|
103
|
+
'UY' => {'action' => 'delete'},
|
104
|
+
'AR' => {'action' => 'update', 'data' => {'name' => 'Argentina', 'code' => 54, 'capital' => 'CABA'}},
|
105
|
+
'BR' => {'action' => 'insert', 'data' => {'name' => 'Brasil'}},
|
106
|
+
'PY' => {'action' => 'insert', 'data' => {'name' => 'Paraguay'}}
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
data/spec/index_spec.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe Index do
|
4
|
+
|
5
|
+
let(:index) { Index.new }
|
6
|
+
|
7
|
+
it 'Initial status' do
|
8
|
+
index.must_be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'Insert' do
|
12
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
13
|
+
|
14
|
+
index.to_h.must_equal 'countries' => {'AR' => digest(name: 'Argentina')}
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Insert existent' do
|
18
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
19
|
+
|
20
|
+
error = proc { index[:countries].insert 'AR', name: 'Argentina' }.must_raise RuntimeError
|
21
|
+
error.message.must_equal 'Countries AR already exists'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'Insert -> Update' do
|
25
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
26
|
+
index[:countries].update 'AR', name: 'Argentina', code: 'ARG'
|
27
|
+
|
28
|
+
index.to_h.must_equal 'countries' => {'AR' => digest(name: 'Argentina', code: 'ARG')}
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'Insert -> Delete' do
|
32
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
33
|
+
index[:countries].insert 'UY', name: 'Uruguay'
|
34
|
+
index[:countries].delete 'AR'
|
35
|
+
|
36
|
+
index.to_h.must_equal 'countries' => {'UY' => digest(name: 'Uruguay')}
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'Insert -> Update -> Delete' do
|
40
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
41
|
+
index[:countries].insert 'UY', name: 'Uruguay'
|
42
|
+
index[:countries].update 'AR', name: 'Argentina', code: 'ARG'
|
43
|
+
index[:countries].delete 'AR'
|
44
|
+
|
45
|
+
index.to_h.must_equal 'countries' => {'UY' => digest(name: 'Uruguay')}
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'Update invalid' do
|
49
|
+
error = proc { index[:countries].update 'INVALID', name: 'Invalid' }.must_raise RuntimeError
|
50
|
+
error.message.must_equal 'Countries INVALID not found'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'Delete invalid' do
|
54
|
+
error = proc { index[:countries].delete 'INVALID' }.must_raise RuntimeError
|
55
|
+
error.message.must_equal 'Countries INVALID not found'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'Ids' do
|
59
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
60
|
+
index[:countries].insert 'UY', name: 'Uruguay'
|
61
|
+
|
62
|
+
index[:countries].ids.must_equal %w(AR UY)
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'Write/Read blob' do
|
66
|
+
index[:countries].insert 'AR', name: 'Argentina'
|
67
|
+
index[:countries].insert 'UY', name: 'Uruguay'
|
68
|
+
|
69
|
+
sha1 = index.write_blob
|
70
|
+
index_2 = Index.read_blob sha1
|
71
|
+
|
72
|
+
index.id.wont_equal index_2.id
|
73
|
+
index.to_h.must_equal index_2.to_h
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe 'Locking' do
|
4
|
+
|
5
|
+
let(:repository) { Repository.new :test }
|
6
|
+
|
7
|
+
def lock(repo)
|
8
|
+
Eternity.locker_storage[repo.name] = :test_process
|
9
|
+
end
|
10
|
+
|
11
|
+
def assert_locked
|
12
|
+
error = proc { yield }.must_raise Locky::Error
|
13
|
+
error.message.must_equal 'test already locked by test_process'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Commit' do
|
17
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
18
|
+
lock repository
|
19
|
+
|
20
|
+
assert_locked { repository.commit author: 'User', message: 'Commit Message' }
|
21
|
+
|
22
|
+
repository.current_commit.must_be_nil
|
23
|
+
repository.changes_count.must_equal 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'Checkout' do
|
27
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
28
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
29
|
+
|
30
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
31
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
32
|
+
|
33
|
+
lock repository
|
34
|
+
|
35
|
+
assert_locked { repository.checkout commit: commit_1.id }
|
36
|
+
|
37
|
+
repository.current_commit.must_equal commit_2
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'Merge' do
|
41
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
42
|
+
commit_1 = repository.commit author: 'User', message: 'Commit 1'
|
43
|
+
|
44
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
45
|
+
commit_2 = repository.commit author: 'User', message: 'Commit 2'
|
46
|
+
|
47
|
+
repository.checkout commit: commit_1.id
|
48
|
+
|
49
|
+
lock repository
|
50
|
+
|
51
|
+
assert_locked { repository.merge commit: commit_2.id }
|
52
|
+
|
53
|
+
repository.current_commit.must_equal commit_1
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'Revert all' do
|
57
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
58
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
59
|
+
repository[:cities].insert 'CABA', name: 'Ciudad Autonoma de Buenos Aires'
|
60
|
+
|
61
|
+
lock repository
|
62
|
+
|
63
|
+
assert_locked { repository.revert }
|
64
|
+
|
65
|
+
repository.changes_count.must_equal 3
|
66
|
+
repository[:countries].count.must_equal 2
|
67
|
+
repository[:cities].count.must_equal 1
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'Revert collection' do
|
71
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
72
|
+
repository[:countries].insert 'UY', name: 'Uruguay'
|
73
|
+
repository[:cities].insert 'CABA', name: 'Ciudad Autonoma de Buenos Aires'
|
74
|
+
|
75
|
+
lock repository
|
76
|
+
|
77
|
+
assert_locked { repository[:countries].revert_all }
|
78
|
+
|
79
|
+
repository.changes_count.must_equal 3
|
80
|
+
repository[:countries].count.must_equal 2
|
81
|
+
repository[:cities].count.must_equal 1
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'Insert' do
|
85
|
+
lock repository
|
86
|
+
|
87
|
+
assert_locked { repository[:countries].insert 'AR', name: 'Argentina' }
|
88
|
+
|
89
|
+
repository.changes_count.must_equal 0
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'Update' do
|
93
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
94
|
+
|
95
|
+
lock repository
|
96
|
+
|
97
|
+
assert_locked { repository[:countries].update 'AR', name: 'Republica Argentina' }
|
98
|
+
|
99
|
+
repository.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'Delete' do
|
103
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
104
|
+
|
105
|
+
lock repository
|
106
|
+
|
107
|
+
assert_locked { repository[:countries].delete 'AR' }
|
108
|
+
|
109
|
+
repository.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'Revert' do
|
113
|
+
repository[:countries].insert 'AR', name: 'Argentina'
|
114
|
+
|
115
|
+
lock repository
|
116
|
+
|
117
|
+
assert_locked { repository[:countries].revert 'AR' }
|
118
|
+
|
119
|
+
repository.delta.must_equal 'countries' => {'AR' => {'action' => 'insert', 'data' => {'name' => 'Argentina'}}}
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|