Skip to content

Commit

Permalink
refactor SummaryTable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afeld committed Aug 28, 2016
1 parent a87ea77 commit 8ccbcee
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions control/summary_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ func docFixture(control string) *xml.XmlDocument {
return doc
}

func getTable(control string) xml.Node {
doc := docFixture(control)
tables, err := doc.Search("//w:tbl")
Expect(err).NotTo(HaveOccurred())
return tables[0]
}

func openControlFixturePath() string {
path := filepath.Join("..", "fixtures", "opencontrols")
path, err := filepath.Abs(path)
Expand All @@ -59,24 +66,20 @@ func openControlFixture() opencontrols.Data {
var _ = Describe("SummaryTable", func() {
Describe("Fill", func() {
It("fills in the Responsible Role for controls", func() {
doc := docFixture("AC-2")
tables, _ := doc.Search("//w:tbl")
table := tables[0]

table := getTable("AC-2")
ct := SummaryTable{Root: table}
openControlData := openControlFixture()

ct.Fill(openControlData)

Expect(table.Content()).To(ContainSubstring(`Responsible Role: Amazon Elastic Compute Cloud: AWS Staff`))
})

It("fills in the Responsible Role for control enhancements", func() {
doc := docFixture("AC-2 (1)")
tables, _ := doc.Search("//w:tbl")
table := tables[0]

table := getTable("AC-2 (1)")
ct := SummaryTable{Root: table}
openControlData := openControlFixture()

ct.Fill(openControlData)

Expect(table.Content()).To(ContainSubstring(`Responsible Role: Amazon Elastic Compute Cloud: AWS Staff`))
Expand Down

0 comments on commit 8ccbcee

Please sign in to comment.