-
Notifications
You must be signed in to change notification settings - Fork 55
/
adding_test.rb
80 lines (65 loc) · 2.43 KB
/
adding_test.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
require File.dirname(__FILE__) + '/../integration_helper'
describe "Adding a mirror in a clean repository" do
before do
FileUtils.rm_rf(TMP_PATH)
FileUtils.mkdir_p(TMP_PATH)
end
describe "from a git repository" do
before do
@shiny = create_git_repo_from_fixture("shiny")
@skit1 = create_git_repo_from_fixture("skit1")
end
it "should add the files and commit" do
in_dir(@shiny) do
`#{BRAID_BIN} add --type git #{@skit1}`
end
file_name = "skit1/layouts/layout.liquid"
output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
$?.should.be.success
output = `git log --pretty=oneline`.split("\n")
output.length.should == 2
output[0].should =~ /Braid: Add mirror 'skit1' at '[0-9a-f]{7}'/
end
it "should create .braids and add the mirror to it" do
in_dir(@shiny) do
`#{BRAID_BIN} add --type git #{@skit1}`
end
braids = YAML::load_file("#{@shiny}/.braids")
braids["skit1"]["squashed"].should == true
braids["skit1"]["url"].should == @skit1
braids["skit1"]["type"].should == "git"
braids["skit1"]["revision"].should.not.be nil
braids["skit1"]["branch"].should == "master"
braids["skit1"]["remote"].should == "braid/skit1"
end
end
describe "from an svn repository" do
before do
@shiny = create_git_repo_from_fixture("shiny")
@skit1 = create_svn_repo_from_fixture("skit1")
end
it "should add the files and commit" do
in_dir(@shiny) do
`#{BRAID_BIN} add --type svn #{@skit1}`
end
file_name = "skit1/layouts/layout.liquid"
output = `diff -U 3 #{File.join(FIXTURE_PATH, file_name)} #{File.join(TMP_PATH, "shiny", file_name)}`
$?.should.be.success
output = `git log --pretty=oneline`.split("\n")
output.length.should == 2
output[0].should =~ /Braid: Add mirror 'skit1' at r1/
end
it "should create .braids and add the mirror to it" do
in_dir(@shiny) do
`#{BRAID_BIN} add --type svn #{@skit1}`
end
braids = YAML::load_file("#{@shiny}/.braids")
braids["skit1"]["squashed"].should == true
braids["skit1"]["url"].should == @skit1
braids["skit1"]["type"].should == "svn"
braids["skit1"]["revision"].should == 1
braids["skit1"]["remote"].should == "braid/skit1"
braids["skit1"]["branch"].should.be == nil
end
end
end