chore: 项目基线(基于 WeKnora 定制版,整理文件忽略规则)
This commit is contained in:
commit
9097ee699d
5769 files changed
+1446466
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
func TestTenantOptionalAPISurface(t *testing.T) {
|
||||
tests := []struct {
|
||||
method string
|
||||
path string
|
||||
want bool
|
||||
}{
|
||||
{http.MethodGet, "/api/v1/auth/me", true},
|
||||
{http.MethodPut, "/api/v1/auth/me", true},
|
||||
{http.MethodPut, "/api/v1/auth/me/preferences", true},
|
||||
{http.MethodPost, "/api/v1/tenants", true},
|
||||
{http.MethodGet, "/api/v1/me/invitations", true},
|
||||
{http.MethodPost, "/api/v1/me/invitations/12/accept", true},
|
||||
{http.MethodGet, "/api/v1/knowledge-bases", false},
|
||||
{http.MethodGet, "/api/v1/tenants", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := isTenantOptionalAPI(tt.path, tt.method); got != tt.want {
|
||||
t.Errorf("isTenantOptionalAPI(%s %s) = %v, want %v", tt.method, tt.path, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveFirstMembershipTarget(t *testing.T) {
|
||||
members := newFakeMemberService()
|
||||
members.seedActive("tenantless-user", 42, types.TenantRoleViewer)
|
||||
tenants := &fakeTenantService{tenant: &types.Tenant{ID: 42}}
|
||||
|
||||
got := resolveFirstMembershipTarget(
|
||||
context.Background(),
|
||||
&types.User{ID: "tenantless-user"},
|
||||
members,
|
||||
tenants,
|
||||
)
|
||||
if got != 42 {
|
||||
t.Fatalf("resolved tenant = %d, want 42", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user