Audit code for consistency with checkpoint #1 of the architecture plan
This commit is contained in:
@@ -35,6 +35,11 @@ func TestValidateDocumentMissingFields(t *testing.T) {
|
||||
mutate: func(doc *SourceDocument) { doc.ID = " \t" },
|
||||
wantErr: "source document id must not be empty",
|
||||
},
|
||||
{
|
||||
name: "id surrounding whitespace",
|
||||
mutate: func(doc *SourceDocument) { doc.ID = " source-1 " },
|
||||
wantErr: "source document id \" source-1 \" must not contain leading or trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "kind",
|
||||
mutate: func(doc *SourceDocument) { doc.Kind = "" },
|
||||
@@ -94,6 +99,11 @@ func TestValidateDocumentMissingUnitFields(t *testing.T) {
|
||||
mutate: func(doc *SourceDocument) { doc.Units[1].ID = "" },
|
||||
wantErr: "source unit[1].id must not be empty",
|
||||
},
|
||||
{
|
||||
name: "id surrounding whitespace",
|
||||
mutate: func(doc *SourceDocument) { doc.Units[1].ID = " u2 " },
|
||||
wantErr: "source unit[1].id \" u2 \" must not contain leading or trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "kind",
|
||||
mutate: func(doc *SourceDocument) { doc.Units[1].Kind = " " },
|
||||
@@ -125,7 +135,7 @@ func TestValidateDocumentMissingUnitFields(t *testing.T) {
|
||||
|
||||
func TestValidateDocumentDuplicateUnitIDs(t *testing.T) {
|
||||
doc := validDocument()
|
||||
doc.Units[1].ID = " u1 "
|
||||
doc.Units[1].ID = "u1"
|
||||
|
||||
err := ValidateDocument(doc)
|
||||
|
||||
@@ -179,16 +189,31 @@ func TestValidateRefMissingUnitIDs(t *testing.T) {
|
||||
ref: SourceRef{StartUnitID: "u1", EndUnitID: "u2"},
|
||||
wantErr: "source ref source_id must not be empty",
|
||||
},
|
||||
{
|
||||
name: "source id surrounding whitespace",
|
||||
ref: SourceRef{SourceID: " source-1 ", StartUnitID: "u1", EndUnitID: "u2"},
|
||||
wantErr: "source ref source_id \" source-1 \" must not contain leading or trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "missing start id",
|
||||
ref: SourceRef{SourceID: "source-1", EndUnitID: "u2"},
|
||||
wantErr: "source ref start_unit_id must not be empty",
|
||||
},
|
||||
{
|
||||
name: "start id surrounding whitespace",
|
||||
ref: SourceRef{SourceID: "source-1", StartUnitID: " u1 ", EndUnitID: "u2"},
|
||||
wantErr: "source ref start_unit_id \" u1 \" must not contain leading or trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "missing end id",
|
||||
ref: SourceRef{SourceID: "source-1", StartUnitID: "u1"},
|
||||
wantErr: "source ref end_unit_id must not be empty",
|
||||
},
|
||||
{
|
||||
name: "end id surrounding whitespace",
|
||||
ref: SourceRef{SourceID: "source-1", StartUnitID: "u1", EndUnitID: " u2 "},
|
||||
wantErr: "source ref end_unit_id \" u2 \" must not contain leading or trailing whitespace",
|
||||
},
|
||||
{
|
||||
name: "unknown start id",
|
||||
ref: SourceRef{SourceID: "source-1", StartUnitID: "u9", EndUnitID: "u2"},
|
||||
|
||||
Reference in New Issue
Block a user