Skip to content
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

Display UPP identifiers in the output. Little bit of optimising query #20

Merged
4 commits merged into from
Oct 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions concordances/cypher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,26 +346,23 @@ func TestNeoReadByAuthorityEmptyConcordancesWhenUnsupportedAuthority(t *testing.
}

func readConceptAndCompare(t *testing.T, expected Concordances, actual Concordances, testName string) {
sort.SliceStable(expected.Concordance, func(i, j int) bool {
return expected.Concordance[i].Concept.ID < expected.Concordance[j].Concept.ID
})
sort.SliceStable(expected.Concordance, func(i, j int) bool {
return expected.Concordance[i].Identifier.Authority < expected.Concordance[j].Identifier.Authority
})
sort.SliceStable(expected.Concordance, func(i, j int) bool {
return expected.Concordance[i].Identifier.IdentifierValue < expected.Concordance[j].Identifier.IdentifierValue
})

sort.SliceStable(actual.Concordance, func(i, j int) bool {
return actual.Concordance[i].Concept.ID < actual.Concordance[j].Concept.ID
fullConcordanceSort(expected.Concordance)
fullConcordanceSort(actual.Concordance)

assert.True(t, reflect.DeepEqual(expected, actual), fmt.Sprintf("Actual aggregated concept differs from expected: Test: %v \n Expected: %v \n Actual: %v", testName, expected, actual))
}

func fullConcordanceSort(concordanceList []Concordance) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nitpicky but fullConcordanceSort should be simpler (i.e. sortConcordances). Naming it full implies theres another alternative sort func that could be used, but there isn't one.

sort.SliceStable(concordanceList, func(i, j int) bool {
return concordanceList[i].Concept.ID < concordanceList[j].Concept.ID
})
sort.SliceStable(actual.Concordance, func(i, j int) bool {
return actual.Concordance[i].Identifier.Authority < actual.Concordance[j].Identifier.Authority
sort.SliceStable(concordanceList, func(i, j int) bool {
return concordanceList[i].Identifier.Authority < concordanceList[j].Identifier.Authority
})
sort.SliceStable(actual.Concordance, func(i, j int) bool {
return actual.Concordance[i].Identifier.IdentifierValue < actual.Concordance[j].Identifier.IdentifierValue
sort.SliceStable(concordanceList, func(i, j int) bool {
return concordanceList[i].Identifier.IdentifierValue < concordanceList[j].Identifier.IdentifierValue
})
assert.True(t, reflect.DeepEqual(expected, actual), fmt.Sprintf("Actual aggregated concept differs from expected: Test: %v \n Expected: %v \n Actual: %v", testName, expected, actual))
}

func getDatabaseConnection(t *testing.T, assert *assert.Assertions) neoutils.NeoConnection {
Expand Down