-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00327ac
commit d02a1db
Showing
11 changed files
with
468 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/test/.repositories | ||
/test/.shards | ||
/test/.libs | ||
/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ release: | |
.PHONY: test | ||
test: | ||
$(CRYSTAL_BIN) run test/*_test.cr | ||
|
||
$(CRYSTAL_BIN) run test/integration/*_test.cr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
require "yaml" | ||
require "./dependency" | ||
require "./errors" | ||
|
||
module Shards | ||
class Spec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require "../integration_helper" | ||
|
||
class CheckCommandTest < Minitest::Test | ||
def test_succeeds_when_all_dependencies_are_installed | ||
metadata = { | ||
dependencies: { web: "*", orm: "*", }, | ||
development_dependencies: { mock: "*" } | ||
} | ||
with_shard(metadata) do | ||
run "shards install" | ||
run "shards check" | ||
end | ||
end | ||
|
||
def test_succeeds_when_dependencies_match_loose_requirements | ||
metadata = { | ||
dependencies: { web: "1.2.0" }, | ||
} | ||
with_shard(metadata) do | ||
run "shards install" | ||
end | ||
|
||
metadata = { | ||
dependencies: { web: "~> 1.1" }, | ||
} | ||
with_shard(metadata) do | ||
run "shards check" | ||
end | ||
end | ||
|
||
def test_fails_when_dependencies_are_missing | ||
metadata = { | ||
dependencies: { web: "*" } | ||
} | ||
with_shard(metadata) { run "shards install" } | ||
|
||
metadata = { | ||
dependencies: { web: "*", orm: "*", }, | ||
development_dependencies: { mock: "*" } | ||
} | ||
with_shard(metadata) do | ||
assert_raises(FailedCommand) { run "shards check" } | ||
end | ||
end | ||
|
||
def test_fails_when_wrong_versions_are_installed | ||
metadata = { | ||
dependencies: { web: "1.0.0" } | ||
} | ||
with_shard(metadata) { run "shards install" } | ||
|
||
metadata = { | ||
dependencies: { web: "2.0.0" } | ||
} | ||
with_shard(metadata) do | ||
assert_raises(FailedCommand) { run "shards check" } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
require "../integration_helper" | ||
|
||
class InstallCommandTest < Minitest::Test | ||
def test_installs_dependencies | ||
metadata = { | ||
dependencies: { web: "*", orm: "*", }, | ||
development_dependencies: { mock: "*" }, | ||
custom_dependencies: { release: "*" }, | ||
} | ||
|
||
with_shard(metadata) do | ||
run "shards install" | ||
|
||
# it installed dependencies (recursively) | ||
assert_installed "web", "2.1.0" | ||
assert_installed "orm", "0.5.0" | ||
assert_installed "pg", "0.2.1" | ||
|
||
# it installed development dependencies (not recursively) | ||
assert_installed "mock" | ||
refute_installed "minitest", "0.1.3" | ||
|
||
# it didn't install custom dependencies | ||
refute_installed "release" | ||
|
||
# it locked dependencies | ||
assert_locked "web", "2.1.0" | ||
assert_locked "orm", "0.5.0" | ||
assert_locked "pg", "0.2.1" | ||
|
||
# it locked development dependencies (not recursively) | ||
assert_locked "mock", "0.1.0" | ||
refute_locked "minitest" | ||
|
||
# it didn't lock custom dependencies | ||
refute_locked "release" | ||
end | ||
end | ||
|
||
def test_installs_dependencies_at_locked_version | ||
metadata = { | ||
dependencies: { web: "1.0.0" }, | ||
development_dependencies: { minitest: "~> 0.1.2" }, | ||
} | ||
lock = { web: "1.0.0", minitest: "0.1.2" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards install" | ||
|
||
assert_installed "web", "1.0.0" | ||
assert_locked "web", "1.0.0" | ||
|
||
assert_installed "minitest", "0.1.2" | ||
assert_locked "minitest", "0.1.2" | ||
end | ||
end | ||
|
||
def test_fails_to_install_when_dependency_requirement_changed | ||
metadata = { dependencies: { web: "2.0.0" }, } | ||
lock = { web: "1.0.0" } | ||
|
||
with_shard(metadata, lock) do | ||
assert_raises(FailedCommand) { run "shards install" } | ||
refute_installed "web" | ||
end | ||
end | ||
|
||
def test_installs_and_updates_lockfile_for_added_dependencies | ||
metadata = { | ||
dependencies: { | ||
web: "~> 1.0.0", | ||
orm: "*" | ||
} | ||
} | ||
lock = { web: "1.0.0" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards install" | ||
|
||
assert_installed "web", "1.0.0" | ||
assert_locked "web", "1.0.0" | ||
|
||
assert_installed "orm", "0.5.0" | ||
assert_locked "orm", "0.5.0" | ||
end | ||
end | ||
|
||
def test_updated_lockfile_on_removed_dependencies | ||
metadata = { dependencies: { web: "~> 1.0.0" } } | ||
lock = { web: "1.0.0", orm: "0.5.0" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards install" | ||
|
||
assert_installed "web", "1.0.0" | ||
assert_locked "web", "1.0.0" | ||
|
||
refute_installed "orm", "0.5.0" | ||
refute_locked "orm", "0.5.0" | ||
end | ||
end | ||
|
||
def test_installs_specified_group_dependencies | ||
metadata = { | ||
dependencies: { web: "*", orm: "*", }, | ||
development_dependencies: { mock: "*" }, | ||
custom_dependencies: { release: "*" }, | ||
} | ||
|
||
with_shard(metadata) do | ||
run "shards install --without development --with custom" | ||
|
||
# it installed dependencies (recursively) | ||
assert_installed "web" | ||
assert_installed "orm" | ||
assert_installed "pg" | ||
|
||
# it didn't install development dependencies | ||
refute_installed "mock" | ||
refute_installed "minitest" | ||
|
||
# it installed custom dependencies (not recursively) | ||
assert_installed "release" | ||
refute_installed "optional" | ||
|
||
# it locked dependencies | ||
assert_locked "web" | ||
assert_locked "orm" | ||
assert_locked "pg" | ||
|
||
# it didn't lock development dependencies | ||
refute_locked "mock" | ||
refute_locked "minitest" | ||
|
||
# it locked custom dependencies | ||
assert_locked "release" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
require "../integration_helper" | ||
|
||
class UpdateCommandTest < Minitest::Test | ||
def test_installs_dependencies | ||
metadata = { | ||
dependencies: { web: "*", orm: "*", }, | ||
development_dependencies: { mock: "*" }, | ||
custom_dependencies: { release: "*" }, | ||
} | ||
|
||
with_shard(metadata) do | ||
run "shards update" | ||
|
||
# it installed dependencies (recursively) | ||
assert_installed "web", "2.1.0" | ||
assert_installed "orm", "0.5.0" | ||
assert_installed "pg", "0.2.1" | ||
|
||
# it installed development dependencies (not recursively) | ||
assert_installed "mock" | ||
refute_installed "minitest", "0.1.3" | ||
|
||
# it didn't install custom dependencies | ||
refute_installed "release" | ||
|
||
# it locked dependencies | ||
assert_locked "web", "2.1.0" | ||
assert_locked "orm", "0.5.0" | ||
assert_locked "pg", "0.2.1" | ||
|
||
# it locked development dependencies (not recursively) | ||
assert_locked "mock", "0.1.0" | ||
refute_locked "minitest" | ||
|
||
# it didn't lock custom dependencies | ||
refute_locked "release" | ||
end | ||
end | ||
|
||
def test_updates_locked_dependencies | ||
metadata = { | ||
dependencies: { web: "2.0.0" }, | ||
development_dependencies: { minitest: "~> 0.1.2" }, | ||
} | ||
lock = { web: "1.0.0", minitest: "0.1.2" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards update" | ||
|
||
assert_installed "web", "2.0.0" | ||
assert_locked "web", "2.0.0" | ||
|
||
assert_installed "minitest", "0.1.3" | ||
assert_locked "minitest", "0.1.3" | ||
end | ||
end | ||
|
||
def test_installs_new_dependencies | ||
metadata = { | ||
dependencies: { | ||
web: "~> 1.1.0", | ||
orm: "*" | ||
} | ||
} | ||
lock = { web: "1.1.2" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards update" | ||
|
||
assert_installed "web", "1.1.2" | ||
assert_locked "web", "1.1.2" | ||
|
||
assert_installed "orm", "0.5.0" | ||
assert_locked "orm", "0.5.0" | ||
end | ||
end | ||
|
||
def test_removes_dependencies | ||
metadata = { dependencies: { web: "~> 1.1.0" } } | ||
lock = { web: "1.0.0", orm: "0.5.0" } | ||
|
||
with_shard(metadata, lock) do | ||
run "shards update" | ||
|
||
assert_installed "web", "1.1.2" | ||
assert_locked "web", "1.1.2" | ||
|
||
refute_installed "orm" | ||
refute_locked "orm" | ||
end | ||
end | ||
end |
Oops, something went wrong.