-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically Enable/disable depenencies tab #311
Changes from 5 commits
5b03a41
9c95458
b7ae0aa
ed3875a
d8c17a1
720a3d7
5c2bbba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,38 +246,101 @@ func TestNormalizeUI(t *testing.T) { | |
}{ | ||
{ | ||
j: &v1.JaegerSpec{}, | ||
expected: &v1.JaegerSpec{}, | ||
expected: &v1.JaegerSpec{UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"dependencies": map[string]interface{}{"menuEnabled": false}})}}, | ||
}, | ||
{ | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es.archive.enabled": "false"})}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es.archive.enabled": "false"})}}, | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Type: "memory"}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Type: "memory"}}, | ||
}, | ||
{ | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"archiveEnabled": true})}}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"archiveEnabled": true, "dependencies": map[string]interface{}{"menuEnabled": false}})}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this wrong - if the storage type is not defined, it should default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general yes, but this tests only normalizeUI which works on any storage |
||
}, | ||
} | ||
for _, test := range tests { | ||
normalizeUI(test.j) | ||
assert.Equal(t, test.expected, test.j) | ||
} | ||
} | ||
|
||
func TestNormalizeUIArchiveButton(t *testing.T) { | ||
tests := []struct { | ||
uiOpts map[string]interface{} | ||
sOpts map[string]string | ||
expected map[string]interface{} | ||
}{ | ||
{}, | ||
{ | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"cassandra-archive.enabled": "true"})}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"cassandra-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"archiveEnabled": true})}}, | ||
uiOpts: map[string]interface{}{}, | ||
sOpts: map[string]string{"es-archive.enabled": "false"}, | ||
expected: map[string]interface{}{}, | ||
}, | ||
{ | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"other": "foo"})}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"other": "foo", "archiveEnabled": true})}}, | ||
uiOpts: map[string]interface{}{}, | ||
sOpts: map[string]string{"es-archive.enabled": "true"}, | ||
expected: map[string]interface{}{"archiveEnabled": true}, | ||
}, | ||
{ | ||
j: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"archiveEnabled": "respectThis"})}}, | ||
expected: &v1.JaegerSpec{Storage: v1.JaegerStorageSpec{Options: v1.NewOptions(map[string]interface{}{"es-archive.enabled": "true"})}, | ||
UI: v1.JaegerUISpec{Options: v1.NewFreeForm(map[string]interface{}{"archiveEnabled": "respectThis"})}}, | ||
uiOpts: map[string]interface{}{}, | ||
sOpts: map[string]string{"cassandra-archive.enabled": "true"}, | ||
expected: map[string]interface{}{"archiveEnabled": true}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{"archiveEnabled": "respectThis"}, | ||
sOpts: map[string]string{"es-archive.enabled": "true"}, | ||
expected: map[string]interface{}{"archiveEnabled": "respectThis"}, | ||
}, | ||
} | ||
for _, test := range tests { | ||
normalizeUI(test.j) | ||
assert.Equal(t, test.expected, test.j) | ||
enableArchiveButton(test.uiOpts, test.sOpts) | ||
assert.Equal(t, test.expected, test.uiOpts) | ||
} | ||
} | ||
|
||
func TestNormalizeUIDependenciesTab(t *testing.T) { | ||
falseVar := false | ||
tests := []struct { | ||
uiOpts map[string]interface{} | ||
storage string | ||
enabled *bool | ||
expected map[string]interface{} | ||
}{ | ||
{ | ||
uiOpts: map[string]interface{}{}, | ||
storage: "memory", | ||
expected: map[string]interface{}{}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{}, | ||
storage: "whateverStorage", | ||
expected: map[string]interface{}{"dependencies": map[string]interface{}{"menuEnabled": false}}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{}, | ||
storage: "whateverStorage", | ||
enabled: &falseVar, | ||
expected: map[string]interface{}{"dependencies": map[string]interface{}{"menuEnabled": false}}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{"dependencies": "respectThis"}, | ||
storage: "whateverStorage", | ||
expected: map[string]interface{}{"dependencies": "respectThis"}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{"dependencies": map[string]interface{}{"menuEnabled": "respectThis"}}, | ||
storage: "whateverStorage", | ||
expected: map[string]interface{}{"dependencies": map[string]interface{}{"menuEnabled": "respectThis"}}, | ||
}, | ||
{ | ||
uiOpts: map[string]interface{}{"dependencies": map[string]interface{}{"foo": "bar"}}, | ||
storage: "whateverStorage", | ||
expected: map[string]interface{}{"dependencies": map[string]interface{}{"foo": "bar", "menuEnabled": false}}, | ||
}, | ||
pavolloffay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
for _, test := range tests { | ||
disableDependenciesTab(test.uiOpts, test.storage, test.enabled) | ||
assert.Equal(t, test.expected, test.uiOpts) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs to be
... || depsEnabled == nil || *depsEnabled == true
- as if thedepsEnabled
is nil, then it means dependencies are enabled by default, doesn't it? So UI config shouldn't be changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normalization of deps spec runs before - so we assuming correct settings here