Skip to content

Commit

Permalink
Added a test for successful storage of markdown in documentation
Browse files Browse the repository at this point in the history
To satisfy DSDEEPB-46. Acceptance Criteria:
```
* There exists a metadata field which can accept a large (10KB) markdown representing tool documentation.
* There exists a unit test that validates that a 10kb string of github markdown is recovered without getting garbled
```

The metadata field exists. Here I'm adding the test. I made a little md file containing various markdown features.
I am concatenating that until it would be >10kb stored, and sending that through the webservice.

I am doing this the full way through the service, not just as a db test, because I want to make sure
serialization/deserialization and spray marshalling etc. do not garble the string.
  • Loading branch information
bradtaylor committed May 8, 2015
1 parent 8f2c5f3 commit f43611a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/test/resources/TESTMARKDOWN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Basic Text
Here is some text that includes some "double quotes" and some 'single quotes' and some "combinations 'thereof'".
It {(also) [includes]} <some\> /extra \special \ncharacters. Think \*they'll be ~ok\?
!@#$%^&*,.?;:=/-+

# Headings
# The largest heading (an <h1> tag)
## The second largest heading (an <h2> tag)
### The third largest heading (an <h3> tag)
#### The fourth largest heading (an <h4> tag)
##### The fifth largest heading (an <h5> tag)
###### The sixth largest heading (an <h6> tag)

# Line Breaks
Below is a line break
=====

# Block-Quotes
> This is a blockquote. It "includes" some quotation marks.
# Text Styling
**This _is_ a string that combines both bolds and italics.**

# Lists
This is a nested list that combines both unordered and ordered list with multiple levels of indenture.
1. Item 1
1. A corollary to the above item.
2. Yet another point to consider.
2. Item 2
* A corollary that does not need to be ordered.
* This is indented four spaces, because it's two spaces further than the item above.
* You might want to consider making a new list.
3. Item 3

# Code Formatting
Here is some text with `monospacing`, within which text appears `**AS**IS`.

# Code Blocks
```
# Here is a block of code
x = 0
x = 2 + 2
what is x
```

# Links
Here is a regular link:
Scala](http://www.scala-lang.org/)
Here are some image links:
[![Build Status](https://travis-ci.org/broadinstitute/agora.svg?branch=master)](https://travis-ci.org/broadinstitute/agora?branch=master)
[![Coverage Status](https://coveralls.io/repos/broadinstitute/agora/badge.svg?branch=master)](https://coveralls.io/r/broadinstitute/agora?branch=master)

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ trait AgoraTestData {

val documentation = "This is the documentation"

def getBigDocumentation: String = {
// Read contents of a test markdown file into a single string.
val markdown = io.Source.fromFile("src/test/resources/TESTMARKDOWN.md").getLines() mkString "\n"
markdown * 7 // NB: File is 1.6 Kb, so 7* that is >10kb, our minimal required storage amount.
}

// NB: save io by storing output.
val bigDocumentation: String = getBigDocumentation

val owner = "bob the builder"

val payload = """task wc {
Expand Down Expand Up @@ -50,4 +59,13 @@ trait AgoraTestData {
owner = owner,
payload = badPayload
)

val testAddRequestBigDoc = new AgoraAddRequest(
namespace = namespace,
name = name,
synopsis = synopsis,
documentation = bigDocumentation,
owner = owner,
payload = payload
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ class ApiServiceSpec extends FlatSpec with Matchers with Directives with Scalate
}
}

"Agora" should "store 10kb of github markdown as method documentation and return it without alteration" in {
Post(ApiUtil.Methods.withLeadingSlash, marshal(testAddRequest)) ~> methodsService.postRoute ~> check {
responseAs[AgoraEntity].documentation === bigDocumentation
}
}
}

0 comments on commit f43611a

Please sign in to comment.