feat(server): add project sharing access control
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package errorx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
sharingmodule "img_infinite_canvas/internal/modules/sharing"
|
||||
)
|
||||
|
||||
func TestHandleShareInviteConflicts(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
err error
|
||||
errorCode string
|
||||
}{
|
||||
{name: "self invite", err: sharingmodule.ErrSelfInvite, errorCode: "share.self_invite"},
|
||||
{name: "member exists", err: sharingmodule.ErrMemberExists, errorCode: "share.member_exists"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
status, body := Handle(context.Background(), tt.err)
|
||||
if status != http.StatusConflict {
|
||||
t.Fatalf("expected status %d, got %d", http.StatusConflict, status)
|
||||
}
|
||||
payload, ok := body.(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("expected map response, got %T", body)
|
||||
}
|
||||
if payload["errorCode"] != tt.errorCode {
|
||||
t.Fatalf("expected error code %q, got %v", tt.errorCode, payload["errorCode"])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user