github.com/nyan233/littlerpc@v0.4.6-0.20230316182519-0c8d5c48abaf/cmd/pxtor/method_test.go (about) 1 package main 2 3 import ( 4 "go/format" 5 "testing" 6 ) 7 8 func TestMethod(t *testing.T) { 9 m := Method{ 10 Receive: Argument{ 11 Name: "p", 12 Type: "TestIProxy", 13 }, 14 ServiceName: "TestService", 15 Name: "Say", 16 InputList: []Argument{ 17 { 18 Name: "ctx", 19 Type: "context.Context", 20 }, 21 { 22 Name: "userName", 23 Type: "string", 24 }, 25 { 26 Name: "password", 27 Type: "string", 28 }, 29 { 30 Name: "id", 31 Type: "int64", 32 }, 33 }, 34 OutputList: []Argument{ 35 { 36 Name: "users", 37 Type: "map[string]int64", 38 }, 39 { 40 Name: "err", 41 Type: "error", 42 }, 43 }, 44 } 45 bytes, err := format.Source([]byte(m.FormatToSync())) 46 if err != nil { 47 t.Fatal(err) 48 } 49 t.Log(string(bytes)) 50 }