Skip to content

Commit

Permalink
Merge pull request #3 from davenverse/initial-tests
Browse files Browse the repository at this point in the history
Add initial tests
  • Loading branch information
ChristopherDavenport committed Nov 19, 2021
2 parents 37d85ee + 25dde18 commit 5e11045
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
name := "curly",

libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %%% "cats-core" % catsV,
// "org.typelevel" %% "cats-effect" % catsEffectV,

// "co.fs2" %% "fs2-core" % fs2V,
// "co.fs2" %% "fs2-io" % fs2V,

"org.http4s" %% "http4s-core" % http4sV,
"org.typelevel" %% "cats-parse" % "0.3.5",
"org.http4s" %%% "http4s-core" % http4sV,
"org.typelevel" %%% "cats-parse" % "0.3.5",
// "org.http4s" %% "http4s-ember-server" % http4sV,
// "org.http4s" %% "http4s-ember-client" % http4sV,
// "org.http4s" %% "http4s-circe" % http4sV,
Expand Down
43 changes: 38 additions & 5 deletions core/src/test/scala/io/chrisdavenport/curly/MainSpec.scala
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))
}

}

0 comments on commit 5e11045

Please sign in to comment.