-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from davenverse/initial-tests
Add initial tests
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 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
43 changes: 38 additions & 5 deletions
43
core/src/test/scala/io/chrisdavenport/curly/MainSpec.scala
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,12 +1,45 @@ | ||
package io.chrisdavenport.curly | ||
|
||
import munit.CatsEffectSuite | ||
import cats.effect._ | ||
|
||
class MainSpec extends CatsEffectSuite { | ||
class MainSpec extends munit.FunSuite { | ||
import Curly._ | ||
|
||
test("Main should exit succesfully") { | ||
assert(true, "Cool") | ||
test("leading 'curl' is case insensitive") { | ||
val cmd = "CuRl 'https://typelevel.org/'" | ||
val actual = Curly.all.parseAll(cmd) | ||
// TODO actually a URI | ||
val expected = List(Unhandled("https://typelevel.org/")) | ||
assertEquals(actual, Right(expected)) | ||
} | ||
|
||
test("only a URL") { | ||
val cmd = "curl 'https://typelevel.org/'" | ||
val actual = Curly.all.parseAll(cmd) | ||
// TODO actually a URI | ||
val expected = List(Unhandled("https://typelevel.org/")) | ||
assertEquals(actual, Right(expected)) | ||
} | ||
|
||
// | ||
// Just asserting lengths for now... | ||
// | ||
|
||
test("with one header") { | ||
val cmd = "curl 'https://typelevel.org/' -H 'User-Agent: Mozilla/5.0'" | ||
val actual = Curly.all.parseAll(cmd) | ||
assertEquals(actual.map(_.length), Right(2)) | ||
} | ||
|
||
test("with two headers") { | ||
val cmd = "curl 'https://typelevel.org/' -H 'User-Agent: Mozilla/5.0' -H 'Connection: keep-alive'" | ||
val actual = Curly.all.parseAll(cmd) | ||
assertEquals(actual.map(_.length), Right(3)) | ||
} | ||
|
||
test("with two headers separated by a long arg") { | ||
val cmd = "curl 'https://typelevel.org/' -H 'User-Agent: Mozilla/5.0' --compress -H 'Connection: keep-alive'" | ||
val actual = Curly.all.parseAll(cmd) | ||
assertEquals(actual.map(_.length), Right(4)) | ||
} | ||
|
||
} |