From 4b72a28f041497ce3c2086e87a633e1303eaa0db Mon Sep 17 00:00:00 2001 From: Daniel Herrmann Date: Sun, 10 Mar 2024 14:03:33 +0100 Subject: [PATCH] tests: split test to check public team discovery in two runs --- pkg/models/teams_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/models/teams_test.go b/pkg/models/teams_test.go index f443f6745..4f0ccd2d2 100644 --- a/pkg/models/teams_test.go +++ b/pkg/models/teams_test.go @@ -149,7 +149,7 @@ func TestTeam_ReadAll(t *testing.T) { assert.Len(t, ts, 1) assert.Equal(t, int64(2), ts[0].ID) }) - t.Run("public", func(t *testing.T) { + t.Run("public discovery disabled", func(t *testing.T) { s := db.NewSession() defer s.Close() @@ -173,16 +173,24 @@ func TestTeam_ReadAll(t *testing.T) { assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind()) ts = teams.([]*Team) assert.Len(t, ts, 5) + }) + + t.Run("public discovery enabled", func(t *testing.T) { + + s := db.NewSession() + defer s.Close() + + team := &Team{} // Enable ServiceEnablePublicTeams feature config.ServiceEnablePublicTeams.Set(true) - // Fetch without public flag should still be the same + // Fetch without public flag should be the same as before team.IncludePublic = false - teams, _, _, err = team.ReadAll(s, doer, "", 1, 50) + teams, _, _, err := team.ReadAll(s, doer, "", 1, 50) require.NoError(t, err) assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind()) - ts = teams.([]*Team) + ts := teams.([]*Team) assert.Len(t, ts, 5) // Fetch with public flag should return more teams