package repo import ( "testing" ) func TestURLToPathName(t *testing.T) { tests := []struct { url string expected string }{ {"https://github.com/user/repo.git", "github.com_user_repo"}, {"https://github.com/user/repo", "github.com_user_repo"}, {"http://gitlab.com/org/project.git", "gitlab.com_org_project"}, {"https://github.com/user/my-repo.git", "github.com_user_my-repo"}, } for _, tc := range tests { result := URLToPathName(tc.url) if result != tc.expected { t.Errorf("URLToPathName(%s): 期望 %s,得到 %s", tc.url, tc.expected, result) } } }