зеркало из https://github.com/golang/pkgsite.git
49 строки
1.0 KiB
Go
49 строки
1.0 KiB
Go
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package internal
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestCandidateModulePaths(t *testing.T) {
|
|
for _, test := range []struct {
|
|
in string
|
|
want []string
|
|
}{
|
|
{"", nil},
|
|
{".", nil},
|
|
{"///foo", nil},
|
|
{"github.com/google", nil},
|
|
{"std", []string{"std"}},
|
|
{"encoding/json", []string{"std"}},
|
|
{
|
|
"example.com/green/eggs/and/ham",
|
|
[]string{
|
|
"example.com/green/eggs/and/ham",
|
|
"example.com/green/eggs/and",
|
|
"example.com/green/eggs",
|
|
"example.com/green",
|
|
"example.com",
|
|
},
|
|
},
|
|
{
|
|
"github.com/google/go-cmp/cmp",
|
|
[]string{"github.com/google/go-cmp/cmp", "github.com/google/go-cmp"},
|
|
},
|
|
{
|
|
"bitbucket.org/ok/sure/no$dollars/allowed",
|
|
[]string{"bitbucket.org/ok/sure"},
|
|
},
|
|
} {
|
|
got := CandidateModulePaths(test.in)
|
|
if !cmp.Equal(got, test.want) {
|
|
t.Errorf("%q: got %v, want %v", test.in, got, test.want)
|
|
}
|
|
}
|
|
}
|