Skip to content

Commit

Permalink
Clean up tests and examples (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
cprussin authored Oct 26, 2017
1 parent f28a9bf commit 0fa3d1a
Show file tree
Hide file tree
Showing 28 changed files with 272 additions and 276 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ SOURCES := $(SRCPATH)/**/*
TESTSOURCES := $(TESTPATH)/**/*
EXAMPLESOURCES := $(EXAMPLESPATH)/**/*

# This is the module name for the entry point for the test suite
TESTMAIN := HTTPure.HTTPureSpec

# Install bower components
$(COMPONENTS): $(BOWERJSON)
$(BOWER) install
Expand All @@ -65,7 +62,7 @@ $(EXAMPLE_INDEX): $(OUTPUT_EXAMPLE) $(BUILD) $(EXAMPLEPATH)/Main.purs
--src-path $(EXAMPLEPATH) \
--include $(SRCPATH) \
--build-path $(BUILD) \
--main $(EXAMPLE) \
--main Examples.$(EXAMPLE).Main \
--to $(EXAMPLE_INDEX)

# Run the example specified by the environment variable EXAMPLE
Expand All @@ -91,7 +88,6 @@ test: $(BUILD) $(TESTSOURCES) $(EXAMPLESOURCES)
--test-path $(TESTPATH) \
--include $(EXAMPLESPATH) \
--build-path $(BUILD) \
--main $(TESTMAIN) \
$(BUILD_OPTIONS)

# Launch a repl with all modules loaded
Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/AsyncResponse/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AsyncResponse where
module Examples.AsyncResponse.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/Headers/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Headers where
module Examples.Headers.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/HelloWorld/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HelloWorld where
module Examples.HelloWorld.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/Middleware/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Middleware where
module Examples.Middleware.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/MultiRoute/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MultiRoute where
module Examples.MultiRoute.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/PathSegments/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module PathSegments where
module Examples.PathSegments.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/Post/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Post where
module Examples.Post.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/QueryParameters/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module QueryParameters where
module Examples.QueryParameters.Main where

import Prelude

Expand Down
2 changes: 1 addition & 1 deletion docs/Examples/SSL/Main.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SSL where
module Examples.SSL.Main where

import Prelude

Expand Down
11 changes: 0 additions & 11 deletions test/HTTPure/HTTPureEffectsSpec.purs

This file was deleted.

113 changes: 0 additions & 113 deletions test/HTTPure/IntegrationSpec.purs

This file was deleted.

37 changes: 0 additions & 37 deletions test/HTTPureSpec.purs

This file was deleted.

18 changes: 9 additions & 9 deletions test/HTTPure/BodySpec.purs → test/Test/HTTPure/BodySpec.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HTTPure.BodySpec where
module Test.HTTPure.BodySpec where

import Prelude

Expand All @@ -7,26 +7,26 @@ import Test.Spec as Spec

import HTTPure.Body as Body

import HTTPure.SpecHelpers as SpecHelpers
import HTTPure.SpecHelpers ((?=))
import Test.HTTPure.TestHelpers as TestHelpers
import Test.HTTPure.TestHelpers ((?=))

readSpec :: SpecHelpers.Test
readSpec :: TestHelpers.Test
readSpec = Spec.describe "read" do
Spec.it "is the body of the Request" do
request <- SpecHelpers.mockRequest "GET" "" "test" []
request <- TestHelpers.mockRequest "GET" "" "test" []
body <- Body.read request
body ?= "test"

writeSpec :: SpecHelpers.Test
writeSpec :: TestHelpers.Test
writeSpec = Spec.describe "write" do
Spec.it "writes the string to the Response body" do
body <- EffClass.liftEff do
resp <- SpecHelpers.mockResponse
resp <- TestHelpers.mockResponse
Body.write resp "test"
pure $ SpecHelpers.getResponseBody resp
pure $ TestHelpers.getResponseBody resp
body ?= "test"

bodySpec :: SpecHelpers.Test
bodySpec :: TestHelpers.Test
bodySpec = Spec.describe "Body" do
readSpec
writeSpec
11 changes: 11 additions & 0 deletions test/Test/HTTPure/HTTPureEffectsSpec.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Test.HTTPure.HTTPureEffectsSpec where

import Prelude

import Test.Spec as Spec

import Test.HTTPure.TestHelpers as TestHelpers

httpureEffectsSpec :: TestHelpers.Test
httpureEffectsSpec = Spec.describe "HTTPureEffects" do
pure unit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module HTTPure.HeadersSpec where
module Test.HTTPure.HeadersSpec where

import Prelude

Expand All @@ -10,10 +10,10 @@ import Test.Spec as Spec
import HTTPure.Headers as Headers
import HTTPure.Lookup ((!!))

import HTTPure.SpecHelpers as SpecHelpers
import HTTPure.SpecHelpers ((?=))
import Test.HTTPure.TestHelpers as TestHelpers
import Test.HTTPure.TestHelpers ((?=))

lookupSpec :: SpecHelpers.Test
lookupSpec :: TestHelpers.Test
lookupSpec = Spec.describe "lookup" do
Spec.describe "when the string is in the header set" do
Spec.describe "when searching with lowercase" do
Expand All @@ -26,13 +26,13 @@ lookupSpec = Spec.describe "lookup" do
Spec.it "is Nothing" do
((Headers.empty !! "X-Test") :: Maybe.Maybe String) ?= Maybe.Nothing

showSpec :: SpecHelpers.Test
showSpec :: TestHelpers.Test
showSpec = Spec.describe "show" do
Spec.it "is a string representing the headers in HTTP format" do
let mock = Headers.header "Test1" "1" <> Headers.header "Test2" "2"
show mock ?= "Test1: 1\nTest2: 2\n\n"

eqSpec :: SpecHelpers.Test
eqSpec :: TestHelpers.Test
eqSpec = Spec.describe "eq" do
Spec.describe "when the two Headers contain the same keys and values" do
Spec.it "is true" do
Expand All @@ -48,7 +48,7 @@ eqSpec = Spec.describe "eq" do
let mock = Headers.header "Test1" "1" <> Headers.header "Test2" "2"
Headers.header "Test1" "1" == mock ?= false

appendSpec :: SpecHelpers.Test
appendSpec :: TestHelpers.Test
appendSpec = Spec.describe "append" do
Spec.describe "when there are multiple keys" do
Spec.it "appends the headers correctly" do
Expand All @@ -66,38 +66,38 @@ appendSpec = Spec.describe "append" do
let mock = Headers.header "Test" "foo" <> Headers.header "Test" "bar"
mock ?= Headers.header "Test" "bar"

readSpec :: SpecHelpers.Test
readSpec :: TestHelpers.Test
readSpec = Spec.describe "read" do
Spec.describe "with no headers" do
Spec.it "is an empty StrMap" do
request <- SpecHelpers.mockRequest "" "" "" []
request <- TestHelpers.mockRequest "" "" "" []
Headers.read request ?= Headers.empty
Spec.describe "with headers" do
Spec.it "is an StrMap with the contents of the headers" do
let testHeader = [Tuple.Tuple "X-Test" "test"]
request <- SpecHelpers.mockRequest "" "" "" testHeader
request <- TestHelpers.mockRequest "" "" "" testHeader
Headers.read request ?= Headers.headers testHeader

writeSpec :: SpecHelpers.Test
writeSpec :: TestHelpers.Test
writeSpec = Spec.describe "write" do
Spec.it "writes the headers to the response" do
header <- EffClass.liftEff do
mock <- SpecHelpers.mockResponse
mock <- TestHelpers.mockResponse
Headers.write mock $ Headers.header "X-Test" "test"
pure $ SpecHelpers.getResponseHeader "X-Test" mock
pure $ TestHelpers.getResponseHeader "X-Test" mock
header ?= "test"

emptySpec :: SpecHelpers.Test
emptySpec :: TestHelpers.Test
emptySpec = Spec.describe "empty" do
Spec.it "is a empty StrMap in an empty Headers" do
show Headers.empty ?= "\n"

headerSpec :: SpecHelpers.Test
headerSpec :: TestHelpers.Test
headerSpec = Spec.describe "header" do
Spec.it "creates a singleton Headers" do
show (Headers.header "X-Test" "test") ?= "X-Test: test\n\n"

headersFunctionSpec :: SpecHelpers.Test
headersFunctionSpec :: TestHelpers.Test
headersFunctionSpec = Spec.describe "headers" do
Spec.it "is equivalent to using Headers.header with <>" do
test ?= expected
Expand All @@ -109,7 +109,7 @@ headersFunctionSpec = Spec.describe "headers" do
]
expected = Headers.header "X-Test-1" "1" <> Headers.header "X-Test-2" "2"

headersSpec :: SpecHelpers.Test
headersSpec :: TestHelpers.Test
headersSpec = Spec.describe "Headers" do
lookupSpec
showSpec
Expand Down
Loading

0 comments on commit 0fa3d1a

Please sign in to comment.