-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rename Table to SummaryTable #38
Changes from 4 commits
e5a5c46
af067bd
a87ea77
8ccbcee
cc537b7
a92ad09
353014d
17ce563
a75cd3b
7666929
c7a2dfa
3d012ac
fe77edd
e961533
56c1473
397aa02
dcca032
21a79d2
72139b5
55db87a
3234e7a
06655b7
ccae626
3965568
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package control | ||
|
||
import ( | ||
"github.com/jbowtie/gokogiri/xml" | ||
"errors" | ||
"fmt" | ||
"regexp" | ||
"strings" | ||
"fmt" | ||
|
||
"github.com/jbowtie/gokogiri/xml" | ||
) | ||
|
||
// findResponsibleRole looks for the Responsible Role cell in the control table. | ||
func findResponsibleRole(ct *Table) (*responsibleRole, error) { | ||
func findResponsibleRole(ct *SummaryTable) (*responsibleRole, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we aren't using |
||
nodes, err := ct.searchSubtree(".//w:tc[starts-with(normalize-space(.), 'Responsible Role')]") | ||
if err != nil { | ||
return nil, err | ||
|
@@ -28,7 +29,7 @@ func findResponsibleRole(ct *Table) (*responsibleRole, error) { | |
// responsibleRole is the container for the responsible role cell. | ||
type responsibleRole struct { | ||
parentNode xml.Node | ||
textNodes *[]xml.Node | ||
textNodes *[]xml.Node | ||
} | ||
|
||
// getContent returns the full string representation of the content of the cell itself. | ||
|
@@ -73,4 +74,4 @@ func (r *responsibleRole) getValue() string { | |
} | ||
} | ||
return result | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,13 @@ func docFixture(control string) *xml.XmlDocument { | |
return doc | ||
} | ||
|
||
func getTable(control string) xml.Node { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that's implied by this file being for summary table tests, no? |
||
doc := docFixture(control) | ||
tables, err := doc.Search("//w:tbl") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice helper! i don't know why I didn't think of this before but instead of having this custom search logic i think we should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is |
||
Expect(err).NotTo(HaveOccurred()) | ||
return tables[0] | ||
} | ||
|
||
func openControlFixturePath() string { | ||
path := filepath.Join("..", "fixtures", "opencontrols") | ||
path, err := filepath.Abs(path) | ||
|
@@ -56,27 +63,23 @@ func openControlFixture() opencontrols.Data { | |
return data | ||
} | ||
|
||
var _ = Describe("Table", func() { | ||
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] | ||
|
||
ct := Table{Root: table} | ||
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] | ||
|
||
ct := Table{Root: table} | ||
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`)) | ||
|
@@ -88,7 +91,7 @@ var _ = Describe("Table", func() { | |
tables, _ := doc.Search("//w:tbl") | ||
table := tables[0] | ||
|
||
ct := Table{Root: table} | ||
ct := SummaryTable{Root: table} | ||
openControlData := openControlFixture() | ||
diff, err := ct.Diff(openControlData) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI that this is go-plus making these kinds of changes automatically. I'm not quite that OCD 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol!! No worries.
go-plus
is runninggo fmt
after every save. side note: we probably need to activate this for add this to our codeclimate rules: https://github.com/codeclimate-community/codeclimate-gofmtThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ (not for this PR) #41