9a5720e8ad
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Full namespace migration: update the Go module path and all import statements from git.mokoconsulting.tech to code.mokoconsulting.tech. Also updates all URL references in templates, workflows, configs, tests, and documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package backend
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/setting"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/test"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestToInternalLFSURL(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.LocalURL, "http://localurl/")()
|
|
defer test.MockVariableValue(&setting.AppSubURL, "/sub")()
|
|
cases := []struct {
|
|
url string
|
|
expected string
|
|
}{
|
|
{"http://appurl/any", ""},
|
|
{"http://appurl/sub/any", ""},
|
|
{"http://appurl/sub/owner/repo/any", ""},
|
|
{"http://appurl/sub/owner/repo/info/any", ""},
|
|
{"http://appurl/sub/owner/repo/info/lfs/any", "http://localurl/api/internal/repo/owner/repo/info/lfs/any"},
|
|
}
|
|
for _, c := range cases {
|
|
assert.Equal(t, c.expected, toInternalLFSURL(c.url), c.url)
|
|
}
|
|
}
|
|
|
|
func TestIsInternalLFSURL(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.LocalURL, "http://localurl/")()
|
|
defer test.MockVariableValue(&setting.InternalToken, "mock-token")()
|
|
cases := []struct {
|
|
url string
|
|
expected bool
|
|
}{
|
|
{"", false},
|
|
{"http://otherurl/api/internal/repo/owner/repo/info/lfs/any", false},
|
|
{"http://localurl/api/internal/repo/owner/repo/info/lfs/any", true},
|
|
{"http://localurl/api/internal/repo/owner/repo/info", false},
|
|
{"http://localurl/api/internal/misc/owner/repo/info/lfs/any", false},
|
|
{"http://localurl/api/internal/owner/repo/info/lfs/any", false},
|
|
{"http://localurl/api/internal/foo/bar", false},
|
|
}
|
|
for _, c := range cases {
|
|
req := newInternalRequestLFS(t.Context(), c.url, "GET", nil, nil)
|
|
assert.Equal(t, c.expected, req != nil, c.url)
|
|
assert.Equal(t, c.expected, isInternalLFSURL(c.url), c.url)
|
|
}
|
|
}
|