fx build fix
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package srequest
|
||||
|
||||
import "github.com/tech/sendico/pkg/model"
|
||||
|
||||
type CreatePriorityGroup struct {
|
||||
Description model.Describable `json:"description"`
|
||||
Priorities []model.Colorable `json:"priorities"`
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package srequest
|
||||
|
||||
import (
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
type CreateProject struct {
|
||||
Project model.Describable `json:"project"`
|
||||
LogoURI *string `json:"logoUrl,omitempty"`
|
||||
PrioriyGroupRef primitive.ObjectID `json:"priorityGroupRef"`
|
||||
StatusGroupRef primitive.ObjectID `json:"statusGroupRef"`
|
||||
Mnemonic string `json:"mnemonic"`
|
||||
}
|
||||
|
||||
type ProjectPreview struct {
|
||||
Projects []primitive.ObjectID `json:"projects"`
|
||||
}
|
||||
|
||||
type TagFilterMode string
|
||||
|
||||
const (
|
||||
TagFilterModeNone TagFilterMode = "none"
|
||||
TagFilterModePresent TagFilterMode = "present"
|
||||
TagFilterModeMissing TagFilterMode = "missing"
|
||||
TagFilterModeIncludeAny TagFilterMode = "includeAny"
|
||||
TagFilterModeIncludeAll TagFilterMode = "includeAll"
|
||||
TagFilterModeExcludeAny TagFilterMode = "excludeAny"
|
||||
)
|
||||
|
||||
type ProjectsFilter = model.ProjectFilterBase
|
||||
@@ -1,11 +0,0 @@
|
||||
package srequest
|
||||
|
||||
import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
// DeleteProject represents a request to delete a project
|
||||
type DeleteProject struct {
|
||||
OrganizationRef primitive.ObjectID `json:"organizationRef"` // If provided, move tasks to this project. If null, delete all tasks
|
||||
MoveTasksToProjectRef *primitive.ObjectID `json:"moveTasksToProjectRef,omitempty"` // If provided, move tasks to this project. If null, delete all tasks
|
||||
}
|
||||
@@ -3,12 +3,10 @@ package srequest
|
||||
import "github.com/tech/sendico/pkg/model"
|
||||
|
||||
type Signup struct {
|
||||
Account model.AccountData `json:"account"`
|
||||
OrganizationName string `json:"organizationName"`
|
||||
OrganizationTimeZone string `json:"organizationTimeZone"`
|
||||
DefaultPriorityGroup CreatePriorityGroup `json:"defaultPriorityGroup"`
|
||||
DefaultStatusGroup CreateStatusGroup `json:"defaultStatusGroup"`
|
||||
AnonymousUser model.Describable `json:"anonymousUser"`
|
||||
OwnerRole model.Describable `json:"ownerRole"`
|
||||
AnonymousRole model.Describable `json:"anonymousRole"`
|
||||
Account model.AccountData `json:"account"`
|
||||
OrganizationName string `json:"organizationName"`
|
||||
OrganizationTimeZone string `json:"organizationTimeZone"`
|
||||
AnonymousUser model.Describable `json:"anonymousUser"`
|
||||
OwnerRole model.Describable `json:"ownerRole"`
|
||||
AnonymousRole model.Describable `json:"anonymousRole"`
|
||||
}
|
||||
|
||||
@@ -5,17 +5,12 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/server/interface/api/srequest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
"github.com/tech/sendico/server/interface/api/srequest"
|
||||
)
|
||||
|
||||
// Helper function to create string pointers
|
||||
func stringPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func TestSignupRequest_JSONSerialization(t *testing.T) {
|
||||
signup := srequest.Signup{
|
||||
Account: model.AccountData{
|
||||
@@ -29,25 +24,6 @@ func TestSignupRequest_JSONSerialization(t *testing.T) {
|
||||
},
|
||||
OrganizationName: "Test Organization",
|
||||
OrganizationTimeZone: "UTC",
|
||||
DefaultPriorityGroup: srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "Default Priority Group",
|
||||
},
|
||||
Priorities: []model.Colorable{
|
||||
{
|
||||
Describable: model.Describable{Name: "High"},
|
||||
Color: stringPtr("#FF0000"),
|
||||
},
|
||||
{
|
||||
Describable: model.Describable{Name: "Medium"},
|
||||
Color: stringPtr("#FFFF00"),
|
||||
},
|
||||
{
|
||||
Describable: model.Describable{Name: "Low"},
|
||||
Color: stringPtr("#00FF00"),
|
||||
},
|
||||
},
|
||||
},
|
||||
AnonymousUser: model.Describable{
|
||||
Name: "Anonymous User",
|
||||
},
|
||||
@@ -75,19 +51,9 @@ func TestSignupRequest_JSONSerialization(t *testing.T) {
|
||||
assert.Equal(t, signup.Account.Password, unmarshaled.Account.Password)
|
||||
assert.Equal(t, signup.OrganizationName, unmarshaled.OrganizationName)
|
||||
assert.Equal(t, signup.OrganizationTimeZone, unmarshaled.OrganizationTimeZone)
|
||||
assert.Equal(t, signup.DefaultPriorityGroup.Description.Name, unmarshaled.DefaultPriorityGroup.Description.Name)
|
||||
assert.Equal(t, len(signup.DefaultPriorityGroup.Priorities), len(unmarshaled.DefaultPriorityGroup.Priorities))
|
||||
assert.Equal(t, signup.AnonymousUser.Name, unmarshaled.AnonymousUser.Name)
|
||||
assert.Equal(t, signup.OwnerRole.Name, unmarshaled.OwnerRole.Name)
|
||||
assert.Equal(t, signup.AnonymousRole.Name, unmarshaled.AnonymousRole.Name)
|
||||
|
||||
// Verify priorities
|
||||
for i, priority := range signup.DefaultPriorityGroup.Priorities {
|
||||
assert.Equal(t, priority.Name, unmarshaled.DefaultPriorityGroup.Priorities[i].Name)
|
||||
if priority.Color != nil && unmarshaled.DefaultPriorityGroup.Priorities[i].Color != nil {
|
||||
assert.Equal(t, *priority.Color, *unmarshaled.DefaultPriorityGroup.Priorities[i].Color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignupRequest_MinimalValidRequest(t *testing.T) {
|
||||
@@ -103,17 +69,6 @@ func TestSignupRequest_MinimalValidRequest(t *testing.T) {
|
||||
},
|
||||
OrganizationName: "Test Organization",
|
||||
OrganizationTimeZone: "UTC",
|
||||
DefaultPriorityGroup: srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "Default",
|
||||
},
|
||||
Priorities: []model.Colorable{
|
||||
{
|
||||
Describable: model.Describable{Name: "Normal"},
|
||||
Color: stringPtr("#000000"),
|
||||
},
|
||||
},
|
||||
},
|
||||
AnonymousUser: model.Describable{
|
||||
Name: "Anonymous",
|
||||
},
|
||||
@@ -139,7 +94,6 @@ func TestSignupRequest_MinimalValidRequest(t *testing.T) {
|
||||
assert.Equal(t, signup.Account.Name, unmarshaled.Account.Name)
|
||||
assert.Equal(t, signup.Account.Login, unmarshaled.Account.Login)
|
||||
assert.Equal(t, signup.OrganizationName, unmarshaled.OrganizationName)
|
||||
assert.Len(t, unmarshaled.DefaultPriorityGroup.Priorities, 1)
|
||||
}
|
||||
|
||||
func TestSignupRequest_InvalidJSON(t *testing.T) {
|
||||
@@ -175,17 +129,6 @@ func TestSignupRequest_UnicodeCharacters(t *testing.T) {
|
||||
},
|
||||
OrganizationName: "测试 Organization",
|
||||
OrganizationTimeZone: "UTC",
|
||||
DefaultPriorityGroup: srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "默认 Priority Group",
|
||||
},
|
||||
Priorities: []model.Colorable{
|
||||
{
|
||||
Describable: model.Describable{Name: "高"},
|
||||
Color: stringPtr("#FF0000"),
|
||||
},
|
||||
},
|
||||
},
|
||||
AnonymousUser: model.Describable{
|
||||
Name: "匿名 User",
|
||||
},
|
||||
@@ -211,102 +154,7 @@ func TestSignupRequest_UnicodeCharacters(t *testing.T) {
|
||||
assert.Equal(t, "测试@example.com", unmarshaled.Account.Login)
|
||||
assert.Equal(t, "Test 用户 Üser", unmarshaled.Account.Name)
|
||||
assert.Equal(t, "测试 Organization", unmarshaled.OrganizationName)
|
||||
assert.Equal(t, "默认 Priority Group", unmarshaled.DefaultPriorityGroup.Description.Name)
|
||||
assert.Equal(t, "高", unmarshaled.DefaultPriorityGroup.Priorities[0].Name)
|
||||
assert.Equal(t, "匿名 User", unmarshaled.AnonymousUser.Name)
|
||||
assert.Equal(t, "所有者", unmarshaled.OwnerRole.Name)
|
||||
assert.Equal(t, "匿名", unmarshaled.AnonymousRole.Name)
|
||||
}
|
||||
|
||||
func TestCreatePriorityGroup_JSONSerialization(t *testing.T) {
|
||||
priorityGroup := srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "Test Priority Group",
|
||||
},
|
||||
Priorities: []model.Colorable{
|
||||
{
|
||||
Describable: model.Describable{Name: "Critical"},
|
||||
Color: stringPtr("#FF0000"),
|
||||
},
|
||||
{
|
||||
Describable: model.Describable{Name: "High"},
|
||||
Color: stringPtr("#FF8000"),
|
||||
},
|
||||
{
|
||||
Describable: model.Describable{Name: "Medium"},
|
||||
Color: stringPtr("#FFFF00"),
|
||||
},
|
||||
{
|
||||
Describable: model.Describable{Name: "Low"},
|
||||
Color: stringPtr("#00FF00"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Test JSON marshaling
|
||||
jsonData, err := json.Marshal(priorityGroup)
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, jsonData)
|
||||
|
||||
// Test JSON unmarshaling
|
||||
var unmarshaled srequest.CreatePriorityGroup
|
||||
err = json.Unmarshal(jsonData, &unmarshaled)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify all fields are properly serialized/deserialized
|
||||
assert.Equal(t, priorityGroup.Description.Name, unmarshaled.Description.Name)
|
||||
assert.Equal(t, len(priorityGroup.Priorities), len(unmarshaled.Priorities))
|
||||
|
||||
for i, priority := range priorityGroup.Priorities {
|
||||
assert.Equal(t, priority.Name, unmarshaled.Priorities[i].Name)
|
||||
if priority.Color != nil && unmarshaled.Priorities[i].Color != nil {
|
||||
assert.Equal(t, *priority.Color, *unmarshaled.Priorities[i].Color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreatePriorityGroup_EmptyPriorities(t *testing.T) {
|
||||
priorityGroup := srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "Empty Priority Group",
|
||||
},
|
||||
Priorities: []model.Colorable{},
|
||||
}
|
||||
|
||||
// Test JSON marshaling
|
||||
jsonData, err := json.Marshal(priorityGroup)
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, jsonData)
|
||||
|
||||
// Test JSON unmarshaling
|
||||
var unmarshaled srequest.CreatePriorityGroup
|
||||
err = json.Unmarshal(jsonData, &unmarshaled)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify empty priorities array is handled correctly
|
||||
assert.Equal(t, priorityGroup.Description.Name, unmarshaled.Description.Name)
|
||||
assert.Empty(t, unmarshaled.Priorities)
|
||||
}
|
||||
|
||||
func TestCreatePriorityGroup_NilPriorities(t *testing.T) {
|
||||
priorityGroup := srequest.CreatePriorityGroup{
|
||||
Description: model.Describable{
|
||||
Name: "Nil Priority Group",
|
||||
},
|
||||
Priorities: nil,
|
||||
}
|
||||
|
||||
// Test JSON marshaling
|
||||
jsonData, err := json.Marshal(priorityGroup)
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, jsonData)
|
||||
|
||||
// Test JSON unmarshaling
|
||||
var unmarshaled srequest.CreatePriorityGroup
|
||||
err = json.Unmarshal(jsonData, &unmarshaled)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify nil priorities is handled correctly
|
||||
assert.Equal(t, priorityGroup.Description.Name, unmarshaled.Description.Name)
|
||||
assert.Nil(t, unmarshaled.Priorities)
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package srequest
|
||||
|
||||
import (
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
type CreateStatus struct {
|
||||
model.Colorable `json:"description"`
|
||||
Icon string `json:"icon"`
|
||||
IsFinal bool `json:"isFinal"`
|
||||
}
|
||||
|
||||
type CreateStatusGroup struct {
|
||||
Description model.Describable `json:"description"`
|
||||
Statuses []CreateStatus `json:"statuses"`
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package sresponse
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
type commentPreviewResponse struct {
|
||||
authResponse `json:",inline"`
|
||||
Comments []model.CommentPreview `json:"comments"`
|
||||
}
|
||||
|
||||
func CommentPreview(logger mlogger.Logger, accessToken *TokenData, comments []model.CommentPreview) http.HandlerFunc {
|
||||
return response.Ok(
|
||||
logger,
|
||||
&commentPreviewResponse{
|
||||
Comments: comments,
|
||||
authResponse: authResponse{AccessToken: *accessToken},
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package sresponse
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
type projectsResponse struct {
|
||||
authResponse `json:",inline"`
|
||||
Projects []model.Project `json:"projects"`
|
||||
}
|
||||
|
||||
func Projects(logger mlogger.Logger, projects []model.Project, accessToken *TokenData) http.HandlerFunc {
|
||||
return response.Ok(logger, projectsResponse{
|
||||
Projects: projects,
|
||||
authResponse: authResponse{AccessToken: *accessToken},
|
||||
})
|
||||
}
|
||||
|
||||
func Project(logger mlogger.Logger, project *model.Project, accessToken *TokenData) http.HandlerFunc {
|
||||
return Projects(logger, []model.Project{*project}, accessToken)
|
||||
}
|
||||
|
||||
type projectPreviewsResponse struct {
|
||||
authResponse `json:",inline"`
|
||||
Previews []model.ProjectPreview `json:"previews"`
|
||||
}
|
||||
|
||||
func ProjectsPreviews(logger mlogger.Logger, previews []model.ProjectPreview, accessToken *TokenData) http.HandlerFunc {
|
||||
return response.Ok(logger, &projectPreviewsResponse{
|
||||
authResponse: authResponse{AccessToken: *accessToken},
|
||||
Previews: previews,
|
||||
})
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package sresponse
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/tech/sendico/pkg/api/http/response"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/model"
|
||||
)
|
||||
|
||||
type statusesResponse struct {
|
||||
authResponse `json:",inline"`
|
||||
Statuses []model.Status `json:"statuses"`
|
||||
}
|
||||
|
||||
func Statuses(logger mlogger.Logger, statuses []model.Status, accessToken *TokenData) http.HandlerFunc {
|
||||
return response.Ok(logger, statusesResponse{
|
||||
Statuses: statuses,
|
||||
authResponse: authResponse{AccessToken: *accessToken},
|
||||
})
|
||||
}
|
||||
|
||||
func Status(logger mlogger.Logger, status *model.Status, accessToken *TokenData) http.HandlerFunc {
|
||||
return Statuses(logger, []model.Status{*status}, accessToken)
|
||||
}
|
||||
Reference in New Issue
Block a user