(t *testing.T)
| 28 | ) |
| 29 | |
| 30 | func TestXMLFormat(t *testing.T) { |
| 31 | const xmlContext = ` |
| 32 | <!-- Settings profiles --> |
| 33 | <profiles> |
| 34 | <!-- Default settings --> |
| 35 | <default> |
| 36 | <!-- The maximum number of threads when running a single query. --> |
| 37 | <max_threads>8</max_threads> |
| 38 | </default> |
| 39 | |
| 40 | <!-- Settings for quries from the user interface --> |
| 41 | <web> |
| 42 | <max_execution_time>600</max_execution_time> |
| 43 | <min_execution_speed>1000000</min_execution_speed> |
| 44 | <timeout_before_checking_execution_speed>15</timeout_before_checking_execution_speed> |
| 45 | |
| 46 | <readonly>1</readonly> |
| 47 | </web> |
| 48 | </profiles> |
| 49 | ` |
| 50 | xmlConfigObj, err := LoadConfig("xml_test", xmlContext, parametersv1alpha1.XML) |
| 51 | assert.Nil(t, err) |
| 52 | |
| 53 | assert.EqualValues(t, xmlConfigObj.Get("profiles.default.max_threads"), 8) |
| 54 | assert.EqualValues(t, xmlConfigObj.Get("profiles.web.min_execution_speed"), 1000000) |
| 55 | assert.EqualValues(t, xmlConfigObj.Get("profiles.web.max_threads"), nil) |
| 56 | |
| 57 | v, _ := xmlConfigObj.GetString("profiles.default.max_threads") |
| 58 | assert.EqualValues(t, v, "8") |
| 59 | v, _ = xmlConfigObj.GetString("profiles.web.min_execution_speed") |
| 60 | assert.EqualValues(t, v, "1000000") |
| 61 | |
| 62 | _, err = xmlConfigObj.GetString("profiles.web.xxxx") |
| 63 | assert.Nil(t, err) |
| 64 | |
| 65 | dumpContext, err := xmlConfigObj.Marshal() |
| 66 | assert.Nil(t, err) |
| 67 | newObj, err := LoadConfig("xml_test", dumpContext, parametersv1alpha1.XML) |
| 68 | assert.Nil(t, err) |
| 69 | assert.EqualValues(t, newObj.GetAllParameters(), xmlConfigObj.GetAllParameters()) |
| 70 | |
| 71 | assert.Nil(t, xmlConfigObj.Update("profiles.web.timeout_before_checking_execution_speed", 200)) |
| 72 | assert.EqualValues(t, xmlConfigObj.Get("profiles.web.timeout_before_checking_execution_speed"), 200) |
| 73 | |
| 74 | assert.Nil(t, xmlConfigObj.RemoveKey("profiles.web.timeout_before_checking_execution_speed.sksds")) |
| 75 | assert.Nil(t, xmlConfigObj.RemoveKey("profiles.web.timeout_before_checking_execution_speed")) |
| 76 | assert.EqualValues(t, xmlConfigObj.Get("profiles.web.timeout_before_checking_execution_speed"), nil) |
| 77 | |
| 78 | assert.Nil(t, xmlConfigObj.Update("profiles.web2.timeout_before_checking_execution_speed", 600)) |
| 79 | assert.EqualValues(t, xmlConfigObj.Get("profiles.web2.timeout_before_checking_execution_speed"), 600) |
| 80 | |
| 81 | assert.Nil(t, xmlConfigObj.Update("profiles_test", "not_exist")) |
| 82 | assert.EqualValues(t, xmlConfigObj.Get("profiles_test"), "not_exist") |
| 83 | } |
| 84 | |
| 85 | func TestEmptyXMLFormat(t *testing.T) { |
| 86 | xmlConfigObj, err := LoadConfig("empty_test", "", parametersv1alpha1.XML) |
nothing calls this directly
no test coverage detected
searching dependent graphs…