mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
godoc: fix tests on Go 1.9
Updates golang/go#11811 Updates golang/go#26531 Change-Id: I9cc7daf551b76c3f06b9dd827c5733513c06895e Reviewed-on: https://go-review.googlesource.com/125816 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
14e571052b
commit
65cc56d756
@ -4,7 +4,10 @@
|
||||
|
||||
package godoc
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"go/build"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseVersionRow(t *testing.T) {
|
||||
tests := []struct {
|
||||
@ -73,6 +76,17 @@ func TestParseVersionRow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// hasTag checks whether a given release tag is contained in the current version
|
||||
// of the go binary.
|
||||
func hasTag(t string) bool {
|
||||
for _, v := range build.Default.ReleaseTags {
|
||||
if t == v {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestAPIVersion(t *testing.T) {
|
||||
av, err := parsePackageAPIInfo()
|
||||
if err != nil {
|
||||
@ -108,6 +122,9 @@ func TestAPIVersion(t *testing.T) {
|
||||
{"type", "archive/tar", "Header", "", ""},
|
||||
{"method", "archive/tar", "Next", "*Reader", ""},
|
||||
} {
|
||||
if tc.want != "" && !hasTag("go"+tc.want) {
|
||||
continue
|
||||
}
|
||||
if got := av.sinceVersionFunc(tc.kind, tc.receiver, tc.name, tc.pkg); got != tc.want {
|
||||
t.Errorf(`sinceFunc("%s", "%s", "%s", "%s") = "%s"; want "%s"`, tc.kind, tc.receiver, tc.name, tc.pkg, got, tc.want)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user