Skip to content

Commit 976260c

Browse files
committed
Add some specs for mercurial bookmarks
1 parent c1a6c2d commit 976260c

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

spec/support/factories.cr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ end
130130

131131
def create_hg_commit(project, message = "new commit")
132132
Dir.cd(hg_path(project)) do
133+
File.write("src/#{project}.cr", "# #{message}", mode: "a")
133134
run "hg commit -A -m #{Process.quote(message)}"
134135
end
135136
end

spec/support/requirement.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ def commit(sha1)
66
Shards::GitCommitRef.new(sha1)
77
end
88

9+
def hg_bookmark(name)
10+
Shards::HgBookmarkRef.new(name)
11+
end
12+
913
def hg_branch(name)
1014
Shards::HgBranchRef.new(name)
1115
end

spec/unit/hg_resolver_spec.cr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ module Shards
2222
create_hg_commit "unreleased", "testing"
2323
checkout_hg_rev "unreleased", "default"
2424

25+
create_hg_repository "unreleased-bm"
26+
create_hg_version_commit "unreleased-bm", "0.1.0"
27+
checkout_new_hg_bookmark "unreleased-bm", "branch"
28+
create_hg_commit "unreleased-bm", "testing"
29+
checkout_hg_rev "unreleased-bm", "default"
30+
2531
create_hg_repository "library", "0.0.1", "0.1.0", "0.1.1", "0.1.2", "0.2.0"
2632

2733
# Create a version tag not prefixed by 'v' which should be ignored
@@ -43,6 +49,9 @@ module Shards
4349
resolver("unreleased").latest_version_for_ref(hg_branch "default").should eq(version "0.1.0+hg.commit.#{hg_commits(:unreleased)[0]}")
4450
resolver("unreleased").latest_version_for_ref(hg_branch "branch").should eq(version "0.1.0+hg.commit.#{hg_commits(:unreleased, "branch")[0]}")
4551
resolver("unreleased").latest_version_for_ref(nil).should eq(version "0.1.0+hg.commit.#{hg_commits(:unreleased)[0]}")
52+
resolver("unreleased-bm").latest_version_for_ref(hg_branch "default").should eq(version "0.1.0+hg.commit.#{hg_commits("unreleased-bm")[0]}")
53+
resolver("unreleased-bm").latest_version_for_ref(hg_bookmark "branch").should eq(version "0.1.0+hg.commit.#{hg_commits("unreleased-bm", "branch")[0]}")
54+
resolver("unreleased-bm").latest_version_for_ref(nil).should eq(version "0.1.0+hg.commit.#{hg_commits("unreleased-bm")[0]}")
4655
resolver("library").latest_version_for_ref(hg_branch "default").should eq(version "0.2.0+hg.commit.#{hg_commits(:library)[0]}")
4756
resolver("library").latest_version_for_ref(nil).should eq(version "0.2.0+hg.commit.#{hg_commits(:library)[0]}")
4857
expect_raises(Shards::Error, "Could not find branch foo for shard \"library\" in the repository #{hg_url(:library)}") do
@@ -59,6 +68,8 @@ module Shards
5968
resolver("library").versions_for(hg_branch "default").should eq(versions ["0.2.0+hg.commit.#{hg_commits(:library)[0]}"])
6069
resolver("unreleased").versions_for(hg_branch "default").should eq(versions ["0.1.0+hg.commit.#{hg_commits(:unreleased)[0]}"])
6170
resolver("unreleased").versions_for(Any).should eq(versions ["0.1.0+hg.commit.#{hg_commits(:unreleased)[0]}"])
71+
resolver("unreleased-bm").versions_for(hg_branch "default").should eq(versions ["0.1.0+hg.commit.#{hg_commits("unreleased-bm")[0]}"])
72+
resolver("unreleased-bm").versions_for(Any).should eq(versions ["0.1.0+hg.commit.#{hg_commits("unreleased-bm")[0]}"])
6273
end
6374

6475
it "read spec for release" do

0 commit comments

Comments
 (0)