...

Source file src/github.com/emicklei/proto/protobuf_test.go

Documentation: github.com/emicklei/proto

     1  package proto
     2  
     3  import (
     4  	"net/http"
     5  	"os"
     6  	"testing"
     7  )
     8  
     9  func fetchAndParse(t *testing.T, url string) *Proto {
    10  	resp, err := http.Get(url)
    11  	if err != nil {
    12  		t.Fatal(url, err)
    13  	}
    14  	defer resp.Body.Close()
    15  	parser := NewParser(resp.Body)
    16  	def, err := parser.Parse()
    17  	if err != nil {
    18  		t.Fatal(url, err)
    19  	}
    20  	t.Log("elements:", len(def.Elements))
    21  	return def
    22  }
    23  
    24  // PB=y go test -v -run ^TestPublicProtoDefinitions$
    25  func TestPublicProtoDefinitions(t *testing.T) {
    26  	if len(os.Getenv("PB")) == 0 {
    27  		t.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 := fetchAndParse(t, each)
    36  		checkParent(def, t)
    37  	}
    38  }
    39  

View as plain text