| 1 | package protoscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.12 `net/http`/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.12 os/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 7 | ) |
| 8 | |
| 9 | func fetchAndParsescip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/fetchAndParse().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#, url string) *Protoscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/Proto# { |
| 10 | resp, err := httpscip-go gomod github.com/golang/go/src go1.12 `net/http`/.Getscip-go gomod github.com/golang/go/src go1.12 `net/http`/Get().(url) |
| 11 | if err != nil { |
| 12 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(url, err) |
| 13 | } |
| 14 | defer resp.Bodyscip-go gomod github.com/golang/go/src go1.12 `net/http`/Response#Body..Closescip-go gomod github.com/golang/go/src go1.12 io/Closer#Close().() |
| 15 | parser := NewParserscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/NewParser().(resp.Bodyscip-go gomod github.com/golang/go/src go1.12 `net/http`/Response#Body.) |
| 16 | def, err := parser.Parsescip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/Parser#Parse().() |
| 17 | if err != nil { |
| 18 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(url, err) |
| 19 | } |
| 20 | t.Logscip-go gomod github.com/golang/go/src go1.12 testing/common#Log().("elements:", len(def.Elementsscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/Proto#Elements.)) |
| 21 | return def |
| 22 | } |
| 23 | |
| 24 | // PB=y go test -v -run ^TestPublicProtoDefinitions$ |
| 25 | func TestPublicProtoDefinitionsscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/TestPublicProtoDefinitions().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 26 | if len(osscip-go gomod github.com/golang/go/src go1.12 os/.Getenvscip-go gomod github.com/golang/go/src go1.12 os/Getenv().("PB")) == 0 { |
| 27 | t.Skipscip-go gomod github.com/golang/go/src go1.12 testing/common#Skip().("PB test not run") |
| 28 | } |
| 29 | for _, each := range []string{ |
| 30 | "https://raw.githubusercontent.com/gogo/protobuf/master/test/thetest.proto", |
| 31 | "https://raw.githubusercontent.com/gogo/protobuf/master/test/theproto3/theproto3.proto", |
| 32 | "https://raw.githubusercontent.com/googleapis/googleapis/master/google/privacy/dlp/v2/dlp.proto", |
| 33 | // "https://raw.githubusercontent.com/envoyproxy/data-plane-api/master/envoy/api/v2/auth/cert.proto", |
| 34 | } { |
| 35 | def := fetchAndParsescip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/fetchAndParse().(t, each) |
| 36 | checkParentscip-go gomod github.com/emicklei/proto . `github.com/emicklei/proto`/checkParent().(def, t) |
| 37 | } |
| 38 | } |