forked from vikunja/vikunja
test: add test to compare getting teams with and without public team feature flag enabled
This commit is contained in:
parent
5975bfd501
commit
8cefe76af5
|
@ -1,61 +1,49 @@
|
|||
-
|
||||
team_id: 1
|
||||
- team_id: 1
|
||||
user_id: 1
|
||||
admin: true
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 1
|
||||
- team_id: 1
|
||||
user_id: 2
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 2
|
||||
- team_id: 2
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 3
|
||||
- team_id: 3
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 4
|
||||
- team_id: 4
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 5
|
||||
- team_id: 5
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 6
|
||||
- team_id: 6
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 7
|
||||
- team_id: 7
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 8
|
||||
- team_id: 8
|
||||
user_id: 1
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 9
|
||||
- team_id: 9
|
||||
user_id: 2
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 10
|
||||
- team_id: 10
|
||||
user_id: 3
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 11
|
||||
- team_id: 11
|
||||
user_id: 8
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 12
|
||||
- team_id: 12
|
||||
user_id: 9
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 13
|
||||
- team_id: 13
|
||||
user_id: 10
|
||||
created: 2018-12-01 15:13:12
|
||||
-
|
||||
team_id: 14
|
||||
- team_id: 14
|
||||
user_id: 10
|
||||
created: 2018-12-01 15:13:12
|
||||
created: 2018-12-01 15:13:12
|
||||
- team_id: 15
|
||||
user_id: 10
|
||||
created: 2018-12-01 15:13:12
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/db"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
|
||||
|
@ -148,6 +149,50 @@ 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) {
|
||||
|
||||
s := db.NewSession()
|
||||
defer s.Close()
|
||||
|
||||
team := &Team{}
|
||||
|
||||
// Default setting is having ServiceEnablePublicTeams disabled
|
||||
// In this default case, fetching teams with or without public flag should return the same result
|
||||
|
||||
// Fetch without public flag
|
||||
teams, _, _, err := team.ReadAll(s, doer, "", 1, 50)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind())
|
||||
ts := teams.([]*Team)
|
||||
assert.Len(t, ts, 5)
|
||||
|
||||
// Fetch with public flag
|
||||
team.IncludePublic = true
|
||||
teams, _, _, err = team.ReadAll(s, doer, "", 1, 50)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind())
|
||||
ts = teams.([]*Team)
|
||||
assert.Len(t, ts, 5)
|
||||
|
||||
// Enable ServiceEnablePublicTeams feature
|
||||
config.ServiceEnablePublicTeams.Set(true)
|
||||
|
||||
// Fetch without public flag should still be the same
|
||||
team.IncludePublic = false
|
||||
teams, _, _, err = team.ReadAll(s, doer, "", 1, 50)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind())
|
||||
ts = teams.([]*Team)
|
||||
assert.Len(t, ts, 5)
|
||||
|
||||
// Fetch with public flag should return more teams
|
||||
team.IncludePublic = true
|
||||
teams, _, _, err = team.ReadAll(s, doer, "", 1, 50)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, reflect.Slice, reflect.TypeOf(teams).Kind())
|
||||
ts = teams.([]*Team)
|
||||
assert.Len(t, ts, 7)
|
||||
})
|
||||
}
|
||||
|
||||
func TestTeam_Update(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user