/
githubmirror
/
gogs
Обзор
Документация
Войти
/
githubmirror
/
gogs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/gitx/submodule_test.go
62 строки
2 KB
ᴊᴏᴇ ᴄʜᴇɴ
all: rename packages ending with "util" to end with "x" (#8182)
16 фев 2026, 21:25
Не верифицирован
16 фев 2026, 21:25
36d56d5
Код
Авторство
О чём код?
package gitx import ( "testing" "github.com/gogs/git-module" "github.com/stretchr/testify/assert" ) func TestInferSubmoduleURL(t *testing.T) { tests := []struct { name string submodule *git.Submodule expURL string }{ { name: "HTTPS URL", submodule: &git.Submodule{ URL: "https://github.com/gogs/docs-api.git", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, expURL: "https://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", }, { name: "SSH URL with port", submodule: &git.Submodule{ URL: "ssh://user@github.com:22/gogs/docs-api.git", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", }, { name: "SSH URL in SCP syntax", submodule: &git.Submodule{ URL: "git@github.com:gogs/docs-api.git", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", }, { name: "relative path", submodule: &git.Submodule{ URL: "../repo2.git", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, expURL: "https://gogs.example.com/user/repo/../repo2/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", }, { name: "bad URL", submodule: &git.Submodule{ URL: "ftp://example.com", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, expURL: "ftp://example.com", }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { assert.Equal(t, test.expURL, InferSubmoduleURL("https://gogs.example.com/user/repo", test.submodule)) }) } }