-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add interfaces for workspace, other yamls. #212
Changes from all commits
a506f4b
ee515d4
7790d94
dd6f629
c2a247a
5815593
e0cc51d
6dad26a
81076bb
e0f6a17
953173b
ac1ff4d
d31854c
35f7b61
fd2e9d2
f7e7f29
2ea8a8d
33328c2
11c8c70
5884e27
e10e6d2
93759b4
42d8925
81180aa
7ae9e50
2c9f6f1
fefa6a9
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/opencontrol/compliance-masonry/lib" | ||
"fmt" | ||
) | ||
|
||
type plugin struct { | ||
lib.Workspace | ||
} | ||
|
||
func simpleDataExtractAndFormat(p plugin) string { | ||
selectJustifications := p.GetJustification("standard", "control") | ||
if len(selectJustifications) == 0 { | ||
return "no data" | ||
} | ||
return selectJustifications[0].SatisfiesData.GetImplementationStatus() | ||
} | ||
|
||
func main() { | ||
workspace, _ := lib.LoadData("sample opencontrol directory", "cert path") | ||
fmt.Println(simpleDataExtractAndFormat(plugin{workspace})) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
"github.com/opencontrol/compliance-masonry/lib/mocks" | ||
commonMocks"github.com/opencontrol/compliance-masonry/lib/common/mocks" | ||
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. Needs a space (right?) 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. whoops! will fix |
||
"github.com/stretchr/testify/assert" | ||
"github.com/opencontrol/compliance-masonry/lib" | ||
) | ||
|
||
func TestSimpleDataExtractAndFormat(t *testing.T) { | ||
// Test the case when there is no data | ||
|
||
// create mock workspace | ||
ws := new(mocks.Workspace) | ||
ws.On("GetJustification", "standard", "control").Return(lib.Verifications{}) | ||
// test function expecting "no data" | ||
p := plugin{ws} | ||
data := simpleDataExtractAndFormat(p) | ||
assert.Equal(t, data, "no data") | ||
|
||
// Test the case when there is data. | ||
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. This should be a separate test. 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. Will do! |
||
|
||
// create mock workspace | ||
ws = new(mocks.Workspace) | ||
satisfies := new(commonMocks.Satisfies) | ||
satisfies.On("GetImplementationStatus").Return("IMPLEMENTED") | ||
ws.On("GetJustification", "standard", "control").Return(lib.Verifications{lib.Verification{SatisfiesData: satisfies}}) | ||
// test function expecting "no data" | ||
p = plugin{ws} | ||
data = simpleDataExtractAndFormat(p) | ||
assert.Equal(t, data, "IMPLEMENTED") | ||
} |
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.
Minor: I'd split this to two lines so it's clearer what the return value of
simpleDataExtractAndFormat()
is.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.
will do!