fix: improve code specification (#231)

This commit is contained in:
sh1luo
2021-08-07 22:02:56 +08:00
committed by Yang Luo
parent a271ef0719
commit 8c66ef6860
36 changed files with 209 additions and 164 deletions

View File

@ -16,6 +16,7 @@ package object
import (
"fmt"
"reflect"
"testing"
"github.com/casbin/casdoor/util"
@ -78,3 +79,27 @@ func TestGetSaltedPassword(t *testing.T) {
salt := "123"
fmt.Printf("%s -> %s\n", password, getSaltedPassword(password, salt))
}
func TestGetMaskedUsers(t *testing.T) {
type args struct {
users []*User
}
tests := []struct {
name string
args args
want []*User
}{
{
name: "1",
args: args{users: []*User{{Password: "casdoor"},{Password: "casbin"}}},
want: []*User{{Password: "***"},{Password: "***"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetMaskedUsers(tt.args.users); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetMaskedUsers() = %v, want %v", got, tt.want)
}
})
}
}