mirror of
https://github.com/strongdm/comply
synced 2024-12-23 14:07:34 +00:00
Check generated documents in tests (#48)
This commit is contained in:
parent
1c80e1ce66
commit
ad2c89ec67
@ -16,18 +16,24 @@ import (
|
||||
// TestReadNarratives calls model.ReadNarratives checking for a valid return value.
|
||||
func TestReadNarratives(t *testing.T) {
|
||||
mockConfig()
|
||||
filePath := fmt.Sprintf("%s/narratives/control.md", getRootPath())
|
||||
fileInfo, _ := os.Lstat(filePath)
|
||||
path.Narratives = func() ([]path.File, error) {
|
||||
filePath := fmt.Sprintf("%s/narratives/control.md", getRootPath())
|
||||
fileInfo, _ := os.Lstat(filePath)
|
||||
return []path.File{
|
||||
{FullPath: filePath, Info: fileInfo},
|
||||
}, nil
|
||||
}
|
||||
|
||||
_, err := ReadNarratives()
|
||||
documents, err := ReadNarratives()
|
||||
if err != nil {
|
||||
t.Fatalf(`ReadNarratives() returned an error %v`, err)
|
||||
}
|
||||
if len(documents) != 1 {
|
||||
t.Fatal(`Invalid number of documents`)
|
||||
}
|
||||
if documents[0].FullPath != filePath {
|
||||
t.Fatalf(`Invalid document path %s`, documents[0].FullPath)
|
||||
}
|
||||
}
|
||||
|
||||
// TestReadNarratives calls model.ReadNarratives checking for a valid return when
|
||||
@ -38,10 +44,13 @@ func TestReadNarrativesWhenThereAreNoNarratives(t *testing.T) {
|
||||
return []path.File{}, nil
|
||||
}
|
||||
|
||||
_, err := ReadNarratives()
|
||||
documents, err := ReadNarratives()
|
||||
if err != nil {
|
||||
t.Fatalf(`ReadNarratives() returned an error %v`, err)
|
||||
}
|
||||
if len(documents) != 0 {
|
||||
t.Fatal(`Invalid number of documents`)
|
||||
}
|
||||
}
|
||||
|
||||
// TestReadNarratives calls model.ReadNarratives checking for an error return when
|
||||
|
Loading…
Reference in New Issue
Block a user