added estra fields for user profile loading

This commit is contained in:
Radu Ioan Fericean
2015-07-15 17:27:06 +03:00
parent e015ef9213
commit 50cafb92d7
7 changed files with 152 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ import (
"testing"
)
func TestMapStruct(t *testing.T) {
func TestStructMapStruct(t *testing.T) {
type TestStruct struct {
Name string
Surname string
@@ -61,3 +61,29 @@ func TestMapStructAddStructs(t *testing.T) {
t.Errorf("Expected: %+v got: %+v", ts, nts)
}
}
func TestStructExtraFields(t *testing.T) {
ts := struct {
Name string
Surname string
Address string
ExtraFields map[string]string
}{
Name: "1",
Surname: "2",
Address: "3",
ExtraFields: map[string]string{
"k1": "v1",
"k2": "v2",
"k3": "v3",
},
}
efMap, err := GetMapExtraFields(ts, "ExtraFields")
if err != nil {
t.Error("Error getting extra fields: ", err)
}
if !reflect.DeepEqual(efMap, ts.ExtraFields) {
t.Errorf("expected: %v got: %v", ts.ExtraFields, efMap)
}
}