move options to dedicated package
Some checks failed
lint / lint (pull_request) Failing after 1m31s
pr / test (pull_request) Failing after 2m37s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-07-29 00:40:58 +03:00
parent b1dbd99ce2
commit 6f6f850af6
84 changed files with 1154 additions and 4521 deletions

View File

@@ -62,6 +62,42 @@ func TestStructFieldsNested(t *testing.T) {
}
}
func TestSetFieldByPathMultiple(t *testing.T) {
var err error
tv := "test_val"
type Str1 struct {
Name []string `json:"name"`
}
val1 := &Str1{}
err = rutil.SetFieldByPath(val1, tv, ".Name")
if err != nil {
t.Fatal(err)
}
if len(val1.Name) != 1 {
t.Fatal("assign error")
} else if val1.Name[0] != tv {
t.Fatal("assign error")
}
type Str2 struct {
Name string `json:"name"`
}
val2 := &Str2{}
err = rutil.SetFieldByPath(val2, []string{tv}, ".Name")
if err != nil {
t.Fatal(err)
}
if len(val1.Name) != 1 {
t.Fatal("assign error")
} else if val1.Name[0] != tv {
t.Fatal("assign error")
}
}
func TestSetFieldByPath(t *testing.T) {
type NestedStr struct {
BBB string `json:"bbb"`