52 lines
796 B
Go
52 lines
796 B
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func Test_getCodeNameByCode(t *testing.T) {
|
||
|
type args struct {
|
||
|
code int32
|
||
|
}
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
args args
|
||
|
want string
|
||
|
want1 bool
|
||
|
}{
|
||
|
{
|
||
|
name: "email",
|
||
|
args: args{
|
||
|
code: 1,
|
||
|
},
|
||
|
want: "email",
|
||
|
want1: true,
|
||
|
},
|
||
|
{
|
||
|
name: "phone",
|
||
|
args: args{
|
||
|
code: 2,
|
||
|
},
|
||
|
want: "phone",
|
||
|
want1: true,
|
||
|
},
|
||
|
{
|
||
|
name: "none",
|
||
|
args: args{
|
||
|
code: 3,
|
||
|
},
|
||
|
want: "",
|
||
|
want1: false,
|
||
|
},
|
||
|
}
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
got, got1 := getCodeNameByCode(tt.args.code)
|
||
|
assert.Equalf(t, tt.want, got, "getCodeNameByCode(%v)", tt.args.code)
|
||
|
assert.Equalf(t, tt.want1, got1, "getCodeNameByCode(%v)", tt.args.code)
|
||
|
})
|
||
|
}
|
||
|
}
|