http autogen testing

This commit is contained in:
Jeff Carr 2025-09-08 03:38:03 -05:00
parent 6a99b7b099
commit f9c8a37491
3 changed files with 35 additions and 8 deletions

View File

@ -37,3 +37,22 @@ goDep.pb.go: goDep.proto
repo.pb.go: repo.proto repo.pb.go: repo.proto
autogenpb --proto repo.proto autogenpb --proto repo.proto
protoc-bad:
cd ~/go/src && protoc \
--proto_path=. \
--proto_path=go.wit.com/lib/protobuf/gitpb \
--go_out=. \
--go_opt=Mgo.wit.com/lib/protobuf/gitpb/repo.proto=go.wit.com/lib/protobuf/gitpb \
--go_opt=MgitTag.proto=go.wit.com/lib/protobuf/gitpb \
--go_opt=MgoDep.proto=go.wit.com/lib/protobuf/gitpb \
go.wit.com/lib/protobuf/gitpb/repo.proto
protoc-good:
cd ~/go/src && protoc \
--proto_path=. \
--go_out=go.wit.com/lib/protobuf/gitpb \
--go_opt=Mrepo.proto=go.wit.com/lib/protobuf/gitpb \
--go_opt=MgitTag.proto=go.wit.com/lib/protobuf/gitpb \
--go_opt=MgoDep.proto=go.wit.com/lib/protobuf/gitpb \
go.wit.com/lib/protobuf/gitpb/repo.proto

View File

@ -1,11 +1,7 @@
package gitpb package gitpb
import ( import (
"bytes"
"net/http" "net/http"
"net/url"
"os"
"os/user"
"go.wit.com/lib/protobuf/httppb" "go.wit.com/lib/protobuf/httppb"
"go.wit.com/log" "go.wit.com/log"
@ -27,7 +23,9 @@ func (p *Repos) SendReply(w http.ResponseWriter, reqPB *httppb.HttpRequest) erro
return err return err
} }
func (p *Repos) HttpPost(baseURL string, route string) (*Repos, error) { /*
// err handling here isn't great
func (p *Repos) HttpPost(baseURL string, route string) (*Repos, *httppb.HttpRequest, error) {
// if you ever have "http://www.wit.com//" GO will regect the server recieving it. // if you ever have "http://www.wit.com//" GO will regect the server recieving it.
// Even though the linux kernel gets the network payload // Even though the linux kernel gets the network payload
// also it never gives you an error about that, it just goes away invisably inside GO // also it never gives you an error about that, it just goes away invisably inside GO
@ -42,7 +40,7 @@ func (p *Repos) HttpPost(baseURL string, route string) (*Repos, error) {
log.Info("reposs PB HttpPost", finalURL.String()) log.Info("reposs PB HttpPost", finalURL.String())
req, err = http.NewRequest(http.MethodPost, finalURL.String(), bytes.NewBuffer(data)) req, err = http.NewRequest(http.MethodPost, finalURL.String(), bytes.NewBuffer(data))
if req == nil { if req == nil {
return nil, err return nil, nil, err
} }
usr, _ := user.Current() usr, _ := user.Current()
@ -52,9 +50,19 @@ func (p *Repos) HttpPost(baseURL string, route string) (*Repos, error) {
newdata, err := httppb.PostReq(req) newdata, err := httppb.PostReq(req)
reqPB, err2 := httppb.ReqToPB(req)
reqPB.URL = finalURL.String()
if err != nil {
reqPB.Errors = append(reqPB.Errors, fmt.Sprintf("%v", err))
}
if err2 != nil {
reqPB.Errors = append(reqPB.Errors, fmt.Sprintf("%v", err2))
}
newpb := NewRepos() newpb := NewRepos()
err = newpb.Unmarshal(newdata) err = newpb.Unmarshal(newdata)
log.Infof("repos PB HttpPost %s sent len(%d) got len(%d)\n", finalURL.String(), p.Len(), newpb.Len()) log.Infof("repos PB HttpPost %s sent len(%d) got len(%d)\n", finalURL.String(), p.Len(), newpb.Len())
return newpb, err return newpb, reqPB, err
} }
*/

View File

@ -72,7 +72,7 @@ message Repo { // `autogenpb
string DevelHash = 27; // hash of the current devel branch string DevelHash = 27; // hash of the current devel branch
} }
message Repos { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui` `autogenpb:nomutex` message Repos { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui` `autogenpb:nomutex` `autogenpb:http`
string uuid = 1; // `autogenpb:uuid:8daaeba1-fb1f-4762-ae6e-95a55d352673` string uuid = 1; // `autogenpb:uuid:8daaeba1-fb1f-4762-ae6e-95a55d352673`
string version = 2; // `autogenpb:version:v4` string version = 2; // `autogenpb:version:v4`
repeated Repo repos = 3; // `autogenpb:append` // generate AppendUnique() function for this repeated Repo repos = 3; // `autogenpb:append` // generate AppendUnique() function for this