Tests: internal/community
internal/community · 17 tests
Each test is named for the property it holds, and runs against a real deployment: there is no mock of the database and no arm that skips when it is absent. The sentence is the test's name read back; the name is what go test -run takes.
community_test.go
- Every group is internally connected —
TestEveryGroupIsInternallyConnected - The partition covers the graph exactly once —
TestThePartitionCoversTheGraphExactlyOnce. Every entity is in exactly one group. - The same graph always partitions the same way —
TestTheSameGraphAlwaysPartitionsTheSameWay - The order edges arrive in does not change the answer —
TestTheOrderEdgesArriveInDoesNotChangeTheAnswer. The same edges in a different order are the same graph. - Group numbers are stable across runs —
TestGroupNumbersAreStableAcrossRuns. And the group numbers are stable too, not only the grouping. - Four unconnected subjects are four subjects —
TestFourUnconnectedSubjectsAreFourSubjects. A person's memory is not one giant component with noise around it. - An unconnected entity is its own subject —
TestAnUnconnectedEntityIsItsOwnSubject. An entity mentioned once, connected to nothing, is a subject with one member rather than something to discard. - One relation between two dense subjects does not merge them —
TestOneRelationBetweenTwoDenseSubjectsDoesNotMergeThem. Two dense subjects joined by one relation are two subjects. - A level exists only where a group was too large —
TestALevelExistsOnlyWhereAGroupWasTooLarge. A level exists exactly where a group was too large to be one subject and was split again, so the depth of the tree is a property of the memory rather than a number somebody chose. - Every child is a subset of its parent —
TestEveryChildIsASubsetOfItsParent. A child is a subset of its parent. - A group nothing divides is left whole —
TestAGroupNothingDividesIsLeftWhole. A group nothing divides is left alone even when it is over the bound. - The hierarchy is reproducible —
TestTheHierarchyIsReproducible. The hierarchy is as reproducible as the partition under it, including the identifiers — a stored community id that moved between runs would point at a different subject. - A graph refuses what it cannot place —
TestAGraphRefusesWhatItCannotPlace - Repeated relations between one pair are one edge —
TestRepeatedRelationsBetweenOnePairAreOneEdge. The same pair asserted five times is one connection of weight five, not five connections. - A relation to itself is not an edge —
TestARelationToItselfIsNotAnEdge. A relation from something to itself informs no grouping decision — a node is already in its own group — and counting it would distort the density every move is measured against. - An empty graph has no subjects —
TestAnEmptyGraphHasNoSubjects. A graph with nothing in it partitions into nothing, rather than into one empty group. - A member connected only outwards survives a split —
TestAMemberConnectedOnlyOutwardsSurvivesASplit. A member of a group whose every relation points outside it has no place in the induced subgraph, and dropping it would lose a member of the community it belongs to.