mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
b9ac51b6c3
* add api filename style * new feature: config.yaml * optimize * optimize logic generation * check hanlder valid * optimize * reactor naming style * optimize * optimize test * optimize gen middleware * format Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn> Co-authored-by: kim <xutao@xiaoheiban.cn>
36 lines
885 B
Go
36 lines
885 B
Go
package name
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIsNamingValid(t *testing.T) {
|
|
style, valid := IsNamingValid("")
|
|
assert.True(t, valid)
|
|
assert.Equal(t, NamingLower, style)
|
|
|
|
_, valid = IsNamingValid("lower1")
|
|
assert.False(t, valid)
|
|
|
|
_, valid = IsNamingValid("lower")
|
|
assert.True(t, valid)
|
|
|
|
_, valid = IsNamingValid("snake")
|
|
assert.True(t, valid)
|
|
|
|
_, valid = IsNamingValid("camel")
|
|
assert.True(t, valid)
|
|
}
|
|
|
|
func TestFormatFilename(t *testing.T) {
|
|
assert.Equal(t, "abc", FormatFilename("a_b_c", NamingLower))
|
|
assert.Equal(t, "ABC", FormatFilename("a_b_c", NamingCamel))
|
|
assert.Equal(t, "a_b_c", FormatFilename("a_b_c", NamingSnake))
|
|
assert.Equal(t, "a", FormatFilename("a", NamingSnake))
|
|
assert.Equal(t, "A", FormatFilename("a", NamingCamel))
|
|
// no flag to convert to snake
|
|
assert.Equal(t, "abc", FormatFilename("abc", NamingSnake))
|
|
}
|