-
-
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.
Fix invalid parsing ot TaskName.get and test coverage.
- Loading branch information
Showing
3 changed files
with
100 additions
and
2 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
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,98 @@ | ||
// Copyright (c) 2021 - 2023 Buijs Software | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
import "package:klutter/klutter.dart"; | ||
import "package:test/test.dart"; | ||
|
||
void main() { | ||
test("Verify parsing consumer init command", () { | ||
final command = Command.from( | ||
script: ScriptName.consumer, | ||
arguments: ["init"]); | ||
|
||
expect(command != null, true, reason: "command should not be null"); | ||
expect(command!.scriptName, ScriptName.consumer); | ||
expect(command.taskName, TaskName.init); | ||
}); | ||
|
||
test("Verify parsing get flutte command", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["get", "flutter=3.10.6.macos.x64"]); | ||
|
||
expect(command != null, true); | ||
}); | ||
|
||
test("When more than 2 arguments are supplied then command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["init", "bom=2023.1.1.beta", "flutter=3.10.6.macos.arm64", "x=y"]); | ||
|
||
expect(command == null, true, reason: "command should be null because too many arguments"); | ||
}); | ||
|
||
test("When an argument has more than one '=' then command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["init", "bom=2023.1.1.beta=woot", "flutter=3.10.6.macos.arm64",]); | ||
|
||
expect(command == null, true, reason: "command should be null argument is invalid"); | ||
}); | ||
|
||
test("When an argument is not a valid option value then command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["init", "woot=2023.1.1.beta", "flutter=3.10.6.macos.arm64",]); | ||
|
||
expect(command == null, true, reason: "command should be null because argument is invalid"); | ||
}); | ||
|
||
test("When get command has more than 1 argument, command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["get", "this", "and" ]); | ||
|
||
expect(command == null, true, reason: "command should be null because get can only have one argument"); | ||
}); | ||
|
||
test("When get command option is invalid, command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["get", "flutter=this=that"]); | ||
|
||
expect(command, null); | ||
}); | ||
|
||
test("When get command option is not named flutter, command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["get", "not=flutter"]); | ||
|
||
expect(command, null); | ||
}); | ||
|
||
test("When get command option flutter is not a valid version, command is null", () { | ||
final command = Command.from( | ||
script: ScriptName.producer, | ||
arguments: ["get", "flutter=not.really.flutterrrr"]); | ||
|
||
expect(command, null); | ||
}); | ||
} |