2020-11-09 17:41:07 +08:00
|
|
|
package format
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
notFormattedStr = `
|
|
|
|
|
type Request struct {
|
|
|
|
|
Name string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Response struct {
|
|
|
|
|
Message string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
service A-api {
|
|
|
|
|
@server(
|
|
|
|
|
handler: GreetHandler
|
|
|
|
|
)
|
|
|
|
|
get /greet/from/:name(Request) returns (Response)
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
formattedStr = `type Request struct {
|
|
|
|
|
Name string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Response struct {
|
|
|
|
|
Message string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
service A-api {
|
|
|
|
|
@server(
|
|
|
|
|
handler: GreetHandler
|
|
|
|
|
)
|
|
|
|
|
get /greet/from/:name(Request) returns (Response)
|
|
|
|
|
}`
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestInlineTypeNotExist(t *testing.T) {
|
2020-11-17 15:25:13 +08:00
|
|
|
r := apiFormat(notFormattedStr)
|
2020-11-09 17:41:07 +08:00
|
|
|
assert.Equal(t, r, formattedStr)
|
|
|
|
|
}
|