@@ -16,7 +16,7 @@ func TestLoadCanonicalControlledMutationEstate(t *testing.T) {
1616 if config .Root .Rollout .MutationMode != "pull-request" ||
1717 config .Root .Discovery .DefaultManagementMode != "observe-only" ||
1818 len (config .Installations ) != 5 || len (config .Mutations ) != 4 ||
19- len (config .Owners ) != 5 || len (config .Selectors ) != 9 {
19+ len (config .Owners ) != 5 || len (config .Selectors ) != 7 {
2020 t .Fatalf ("config = %#v" , config )
2121 }
2222}
@@ -40,7 +40,6 @@ func TestCompileTwoThousandRepositoriesAndForksDeterministically(t *testing.T) {
4040 if len (findings ) != 0 || len (compiled .Repositories ) != 2000 {
4141 t .Fatalf ("repositories=%d findings=%#v" , len (compiled .Repositories ), findings )
4242 }
43- forks := 0
4443 managed := 0
4544 for index , assignment := range compiled .Repositories {
4645 if assignment .ProviderID != int64 (index + 1000 ) ||
@@ -55,16 +54,22 @@ func TestCompileTwoThousandRepositoriesAndForksDeterministically(t *testing.T) {
5554 } else if assignment .ManagementMode != "observe-only" {
5655 t .Fatalf ("observe-only assignment[%d] = %#v" , index , assignment )
5756 }
58- if assignment .MatchedSelector == "personal-forks" ||
59- assignment .MatchedSelector == "organization-forks" {
60- forks ++
57+ // Half the observations are forks. None of them is classified as
58+ // one: a repository belongs to the account that holds it, so a fork
59+ // lands in exactly the selector its non-fork sibling would.
60+ if assignment .Owner == "example-user" && assignment .MatchedSelector != "personal-sources" {
61+ t .Fatalf ("personal assignment[%d] = %#v" , index , assignment )
62+ }
63+ if assignment .Owner == "example-org" && assignment .MatchedSelector != "organization-sources" {
64+ t .Fatalf ("organization assignment[%d] = %#v" , index , assignment )
6165 }
6266 }
63- if forks != 1000 {
64- t .Fatalf ("fork assignments = %d, want 1000" , forks )
65- }
66- if managed != 500 {
67- t .Fatalf ("managed assignments = %d, want 500" , managed )
67+ // Every organization repository is managed now, forks included. That is
68+ // the consequence of dropping fork classification: a managed account
69+ // manages everything it holds, and a fork stops being a way to sit
70+ // outside that. Half of these observations are forks.
71+ if managed != 1000 {
72+ t .Fatalf ("managed assignments = %d, want 1000" , managed )
6873 }
6974
7075 for left , right := 0 , len (repositories )- 1 ; left < right ; left , right = left + 1 , right - 1 {
@@ -81,7 +86,7 @@ func TestCompileTwoThousandRepositoriesAndForksDeterministically(t *testing.T) {
8186func TestCompileRejectsSelectorConflictAndUnknownOwner (t * testing.T ) {
8287 t .Parallel ()
8388 config := loadCanonical (t )
84- conflict := organizationForksSelector (t , config )
89+ conflict := organizationSourcesSelector (t , config )
8590 conflict .Selector .ID = "conflicting-selector"
8691 config .Selectors = append (config .Selectors , conflict )
8792 _ , findings := Compile (config , []ObservedRepository {{
@@ -147,8 +152,9 @@ func TestCompileRoutesServerRepositoriesByNamePrefix(t *testing.T) {
147152 len (got .Portfolios ) != 1 || got .Portfolios [0 ] != "portfolio:servers" {
148153 t .Fatalf ("personal server repository = %#v" , got )
149154 }
150- if got := byID [13 ]; got .MatchedSelector != "organization-forks" ||
151- ! containsString (got .Portfolios , "portfolio:forks" ) {
155+ // The name prefix decides, and being a fork no longer overrides it.
156+ if got := byID [13 ]; got .MatchedSelector != "organization-servers" ||
157+ ! containsString (got .Portfolios , "portfolio:servers" ) {
152158 t .Fatalf ("server-named organization fork repository = %#v" , got )
153159 }
154160}
@@ -196,13 +202,13 @@ func TestCompilePreservesArchivedObservation(t *testing.T) {
196202 }
197203}
198204
199- func organizationForksSelector (t * testing.T , config Config ) Selector {
205+ func organizationSourcesSelector (t * testing.T , config Config ) Selector {
200206 t .Helper ()
201207 for _ , selector := range config .Selectors {
202- if selector .Selector .ID == "organization-forks " {
208+ if selector .Selector .ID == "organization-sources " {
203209 return selector
204210 }
205211 }
206- t .Fatalf ("organization-forks selector not found in %#v" , config .Selectors )
212+ t .Fatalf ("organization-sources selector not found in %#v" , config .Selectors )
207213 return Selector {}
208214}
0 commit comments