github.com/yylbfyl/glide@v0.0.0-20230427033633-b23b3139ece7/util/util_test.go (about)

     1  package util
     2  
     3  import "testing"
     4  
     5  func TestGetRootFromPackage(t *testing.T) {
     6  	urlList := map[string]string{
     7  		"github.com/yylbfyl/VCSTestRepo":                       "github.com/yylbfyl/VCSTestRepo",
     8  		"bitbucket.org/mattfarina/testhgrepo":                      "bitbucket.org/mattfarina/testhgrepo",
     9  		"launchpad.net/govcstestbzrrepo/trunk":                     "launchpad.net/govcstestbzrrepo/trunk",
    10  		"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo":       "launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo",
    11  		"launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk": "launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo",
    12  		"git.launchpad.net/govcstestgitrepo":                       "git.launchpad.net/govcstestgitrepo",
    13  		"git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo":    "git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo",
    14  		"hub.jazz.net/git/user/pkgname":                            "hub.jazz.net/git/user/pkgname",
    15  		"hub.jazz.net/git/user/pkgname/subpkg/subpkg/subpkg":       "hub.jazz.net/git/user/pkgname",
    16  		"farbtastic.googlecode.com/svn/":                           "farbtastic.googlecode.com/svn/",
    17  		"farbtastic.googlecode.com/svn/trunk":                      "farbtastic.googlecode.com/svn/trunk",
    18  		"code.google.com/p/farbtastic":                             "code.google.com/p/farbtastic",
    19  		"code.google.com/p/plotinum":                               "code.google.com/p/plotinum",
    20  		"example.com/foo/bar.git":                                  "example.com/foo/bar.git",
    21  		"example.com/foo/bar.svn":                                  "example.com/foo/bar.svn",
    22  		"example.com/foo/bar/baz.bzr":                              "example.com/foo/bar/baz.bzr",
    23  		"example.com/foo/bar/baz.hg":                               "example.com/foo/bar/baz.hg",
    24  		"gopkg.in/mgo.v2":                                          "gopkg.in/mgo.v2",
    25  		"gopkg.in/mgo.v2/txn":                                      "gopkg.in/mgo.v2",
    26  		"gopkg.in/nowk/assert.v2":                                  "gopkg.in/nowk/assert.v2",
    27  		"gopkg.in/nowk/assert.v2/tests":                            "gopkg.in/nowk/assert.v2",
    28  		"golang.org/x/net":                                         "golang.org/x/net",
    29  		"golang.org/x/net/context":                                 "golang.org/x/net",
    30  	}
    31  
    32  	for u, c := range urlList {
    33  		repo := GetRootFromPackage(u)
    34  		if repo != c {
    35  			t.Errorf("getRepoRootFromPackage expected %s but got %s", c, repo)
    36  		}
    37  	}
    38  }