protoutil: add support for converting arbitrary protobuf messages into structs (#3106)

This commit is contained in:
Caleb Doxsey 2022-03-08 12:21:22 -07:00 committed by GitHub
parent 8cc9c9c8fb
commit 9e4edb8003
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -3,6 +3,8 @@ package protoutil
import (
"testing"
"google.golang.org/protobuf/types/known/apipb"
"github.com/pomerium/pomerium/internal/testutil"
)
@ -28,6 +30,7 @@ func TestToValue(t *testing.T) {
{"uint64", uint64(1), "1"},
{"[]interface{}", []interface{}{1, 2, 3, 4}, `[1,2,3,4]`},
{"map[string]interface{}", map[string]interface{}{"k1": "v1", "k2": "v2"}, `{"k1":"v1","k2":"v2"}`},
{"Message", &apipb.Method{Name: "example"}, `{"name": "example"}`},
}
for _, tc := range testCases {
tc := tc