-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for the remove command.
- Loading branch information
1 parent
d33db13
commit 0f8329a
Showing
2 changed files
with
130 additions
and
0 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
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,129 @@ | ||
#use-added-syntax(tests) | ||
defpackage slm/tests/commands/remove: | ||
import core | ||
import collections | ||
|
||
import semver | ||
|
||
import slm/commands/remove | ||
import slm/toml | ||
import slm/dependency | ||
|
||
import slm/tests/test-tools | ||
|
||
deftest(rm-cmd) test-remove-basic: | ||
|
||
val input = SlmToml( | ||
"my-pkg", | ||
"0.1.3", | ||
One("jstanza") | ||
to-hashtable<String, Dependency>([ | ||
"stanza-toml" => GitDependency("stanza-toml", "StanzaOrg/stanza-toml", SemanticVersion(0,3,1), "") | ||
]) | ||
) | ||
|
||
val uut = remove-dependency(input, ["stanza-toml"]) | ||
|
||
#EXPECT( name(uut) == "my-pkg" ) | ||
#EXPECT( version(uut) == "0.1.3" ) | ||
#EXPECT( compiler?(uut) == One("jstanza")) | ||
|
||
val deps = dependencies(uut) | ||
val names = to-tuple $ keys(deps) | ||
#EXPECT( length(names) == 0 ) | ||
|
||
|
||
deftest(rm-cmd) test-remove-not-found: | ||
|
||
val input = SlmToml( | ||
"my-pkg", | ||
"0.1.3", | ||
None(), | ||
to-hashtable<String, Dependency>([]) | ||
) | ||
|
||
defn attempt-remove () : | ||
remove-dependency(input, ["stanza-toml"]) | ||
|
||
val msg = expect-throw(attempt-remove) | ||
#EXPECT(prefix?(value!(msg), "The following dependencies were not found")) | ||
|
||
|
||
deftest(rm-cmd) test-remove-with-others: | ||
|
||
val input = SlmToml( | ||
"my-pkg", | ||
"0.1.3", | ||
One("jstanza") | ||
to-hashtable<String, Dependency>([ | ||
"stanza-toml" => GitDependency("stanza-toml", "StanzaOrg/stanza-toml", SemanticVersion(0,3,1), "") | ||
"semver" => GitDependency("semver", "StanzaOrg/semver", SemanticVersion(0,1,4), "") | ||
"maybe-utils" => GitDependency("maybe-utils", "StanzaOrg/maybe-utils", SemanticVersion(0,1,5), "") | ||
"scooby-doo" => PathDependency("scooby-doo", "/where/are/you") | ||
]) | ||
) | ||
|
||
val uut = remove-dependency(input, ["semver"]) | ||
|
||
#EXPECT( name(uut) == "my-pkg" ) | ||
#EXPECT( version(uut) == "0.1.3" ) | ||
#EXPECT( compiler?(uut) == One("jstanza")) | ||
|
||
val deps = dependencies(uut) | ||
val names = to-tuple $ keys(deps) | ||
val expNames = ["stanza-toml", "maybe-utils", "scooby-doo"] | ||
#EXPECT( length(names) == length(expNames) ) | ||
|
||
for name in names do: | ||
#EXPECT(contains?(expNames, name)) | ||
|
||
deftest(rm-cmd) test-remove-multiple: | ||
|
||
val input = SlmToml( | ||
"my-pkg", | ||
"0.1.3", | ||
One("jstanza") | ||
to-hashtable<String, Dependency>([ | ||
"stanza-toml" => GitDependency("stanza-toml", "StanzaOrg/stanza-toml", SemanticVersion(0,3,1), "") | ||
"semver" => GitDependency("semver", "StanzaOrg/semver", SemanticVersion(0,1,4), "") | ||
"maybe-utils" => GitDependency("maybe-utils", "StanzaOrg/maybe-utils", SemanticVersion(0,1,5), "") | ||
"scooby-doo" => PathDependency("scooby-doo", "/where/are/you") | ||
]) | ||
) | ||
|
||
val uut = remove-dependency(input, ["semver", "scooby-doo"]) | ||
|
||
#EXPECT( name(uut) == "my-pkg" ) | ||
#EXPECT( version(uut) == "0.1.3" ) | ||
#EXPECT( compiler?(uut) == One("jstanza")) | ||
|
||
val deps = dependencies(uut) | ||
val names = to-tuple $ keys(deps) | ||
val expNames = ["stanza-toml", "maybe-utils"] | ||
#EXPECT( length(names) == length(expNames) ) | ||
|
||
for name in names do: | ||
#EXPECT(contains?(expNames, name)) | ||
|
||
|
||
deftest(rm-cmd) test-remove-multiple-with-fail: | ||
|
||
val input = SlmToml( | ||
"my-pkg", | ||
"0.1.3", | ||
One("jstanza") | ||
to-hashtable<String, Dependency>([ | ||
"stanza-toml" => GitDependency("stanza-toml", "StanzaOrg/stanza-toml", SemanticVersion(0,3,1), "") | ||
"semver" => GitDependency("semver", "StanzaOrg/semver", SemanticVersion(0,1,4), "") | ||
"maybe-utils" => GitDependency("maybe-utils", "StanzaOrg/maybe-utils", SemanticVersion(0,1,5), "") | ||
"scooby-doo" => PathDependency("scooby-doo", "/where/are/you") | ||
]) | ||
) | ||
|
||
defn attempt-remove (): | ||
remove-dependency(input, ["semver", "scooby-doo", "not-existing"]) | ||
|
||
val msg = expect-throw(attempt-remove) | ||
|
||
#EXPECT(prefix?(value!(msg), "The following dependencies were not found")) | ||
|