Refactor team configuration tests to remove uploader and avatar agent assertions
- Removed assertions for the uploader and avatar agent fields in the team configuration tests, as these fields are no longer preserved in the public configuration. - Updated the GetTeamConfigPublic function to reflect the changes in the TeamConfig structure, ensuring only relevant fields are included in the public configuration. - Adjusted test cases to maintain coverage while aligning with the updated configuration structure.
This commit is contained in:
parent
376befc21b
commit
7549a890e5
4 changed files with 9 additions and 41 deletions
|
|
@ -105,8 +105,6 @@ func TestGetTeamConfigPublic(t *testing.T) {
|
||||||
assert.Equal(t, originalConfig.Role, publicConfig.Role, "Role should be preserved")
|
assert.Equal(t, originalConfig.Role, publicConfig.Role, "Role should be preserved")
|
||||||
assert.Equal(t, originalConfig.Roles, publicConfig.Roles, "Roles should be preserved")
|
assert.Equal(t, originalConfig.Roles, publicConfig.Roles, "Roles should be preserved")
|
||||||
assert.Equal(t, originalConfig.Invite, publicConfig.Invite, "Invite config should be preserved")
|
assert.Equal(t, originalConfig.Invite, publicConfig.Invite, "Invite config should be preserved")
|
||||||
assert.Equal(t, originalConfig.Uploader, publicConfig.Uploader, "Uploader should be preserved (public field)")
|
|
||||||
assert.Equal(t, originalConfig.AvatarAgent, publicConfig.AvatarAgent, "AvatarAgent should be preserved (public field)")
|
|
||||||
|
|
||||||
// Test robot configuration
|
// Test robot configuration
|
||||||
if originalConfig.Robot != nil {
|
if originalConfig.Robot != nil {
|
||||||
|
|
|
||||||
|
|
@ -51,19 +51,6 @@ func TestTeamConfigStructure(t *testing.T) {
|
||||||
// Verify team config structure is valid
|
// Verify team config structure is valid
|
||||||
assert.IsType(t, &user.TeamConfig{}, teamConfig, "Should return correct team config type")
|
assert.IsType(t, &user.TeamConfig{}, teamConfig, "Should return correct team config type")
|
||||||
|
|
||||||
// Test uploader field (public field)
|
|
||||||
if teamConfig.Uploader != "" {
|
|
||||||
t.Logf("Uploader configured: %s", teamConfig.Uploader)
|
|
||||||
assert.NotEmpty(t, teamConfig.Uploader, "Uploader should not be empty if set")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test avatar_agent field (public field, optional)
|
|
||||||
if teamConfig.AvatarAgent != "" {
|
|
||||||
t.Logf("Avatar agent configured: %s", teamConfig.AvatarAgent)
|
|
||||||
} else {
|
|
||||||
t.Log("Avatar agent not configured (optional field)")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test roles configuration
|
// Test roles configuration
|
||||||
if teamConfig.Roles != nil {
|
if teamConfig.Roles != nil {
|
||||||
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")
|
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")
|
||||||
|
|
@ -176,19 +163,6 @@ func TestTeamConfigAPI(t *testing.T) {
|
||||||
// Verify team config structure
|
// Verify team config structure
|
||||||
assert.IsType(t, &user.TeamConfig{}, &teamConfig, "Should return correct team config type")
|
assert.IsType(t, &user.TeamConfig{}, &teamConfig, "Should return correct team config type")
|
||||||
|
|
||||||
// Test uploader field (public field)
|
|
||||||
if teamConfig.Uploader != "" {
|
|
||||||
t.Logf("API returned uploader: %s", teamConfig.Uploader)
|
|
||||||
assert.NotEmpty(t, teamConfig.Uploader, "Uploader should not be empty if set")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test avatar_agent field (public field, optional)
|
|
||||||
if teamConfig.AvatarAgent != "" {
|
|
||||||
t.Logf("API returned avatar_agent: %s", teamConfig.AvatarAgent)
|
|
||||||
} else {
|
|
||||||
t.Log("API returned no avatar_agent (optional field)")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test roles if present
|
// Test roles if present
|
||||||
if teamConfig.Roles != nil {
|
if teamConfig.Roles != nil {
|
||||||
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")
|
assert.IsType(t, []*user.TeamRole{}, teamConfig.Roles, "Roles should be slice of TeamRole pointers")
|
||||||
|
|
|
||||||
|
|
@ -344,12 +344,10 @@ func GetTeamConfigPublic(locale string) *TeamConfig {
|
||||||
|
|
||||||
// Create a deep copy of the config to avoid modifying the original
|
// Create a deep copy of the config to avoid modifying the original
|
||||||
publicConfig := &TeamConfig{
|
publicConfig := &TeamConfig{
|
||||||
Type: originalConfig.Type,
|
Type: originalConfig.Type,
|
||||||
Role: originalConfig.Role,
|
Role: originalConfig.Role,
|
||||||
Roles: originalConfig.Roles, // Shallow copy is OK for roles (read-only)
|
Roles: originalConfig.Roles, // Shallow copy is OK for roles (read-only)
|
||||||
Invite: originalConfig.Invite, // Shallow copy is OK for invite config (read-only)
|
Invite: originalConfig.Invite, // Shallow copy is OK for invite config (read-only)
|
||||||
Uploader: originalConfig.Uploader, // Public information
|
|
||||||
AvatarAgent: originalConfig.AvatarAgent, // Public information
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle robot config - create a copy without sensitive fields
|
// Handle robot config - create a copy without sensitive fields
|
||||||
|
|
|
||||||
|
|
@ -680,13 +680,11 @@ type RobotDefaults struct {
|
||||||
|
|
||||||
// TeamConfig represents the team configuration loaded from DSL files
|
// TeamConfig represents the team configuration loaded from DSL files
|
||||||
type TeamConfig struct {
|
type TeamConfig struct {
|
||||||
Roles []*TeamRole `json:"roles,omitempty"`
|
Roles []*TeamRole `json:"roles,omitempty"`
|
||||||
Robot *RobotConfig `json:"robot,omitempty"`
|
Robot *RobotConfig `json:"robot,omitempty"`
|
||||||
Invite *InviteConfig `json:"invite,omitempty"`
|
Invite *InviteConfig `json:"invite,omitempty"`
|
||||||
Type string `json:"type,omitempty"` // Default subscription type for new teams
|
Type string `json:"type,omitempty"` // Default subscription type for new teams
|
||||||
Role string `json:"role,omitempty"` // Default user role for team creator
|
Role string `json:"role,omitempty"` // Default user role for team creator
|
||||||
Uploader string `json:"uploader,omitempty"` // Uploader for avatar and attachments (default: __yao.attachment)
|
|
||||||
AvatarAgent string `json:"avatar_agent,omitempty"` // Agent ID for avatar generation (optional)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TeamRole represents a team role configuration
|
// TeamRole represents a team role configuration
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue