hotfix: return error instead of log at FromMapAndOption (#5381)

* hotfix: return error instead of log at `FromMapAndOption`

* chore: show error message

* hotfix: use correct function

* hotix: use `t.Helper()` and fix `t *testing.T order

* hotfix: wrapt the error of `FromMapAndOption`

* hotfix: meaningful message for an error

* hotfix: summarize in one line

* hotfix: fix the abandoned error and show meaningful message

* hotfix: start with helper function

* Keep TODO comment
This commit is contained in:
chansuke
2023-10-28 06:01:47 +09:00
committed by GitHub
parent bd435d4154
commit e002b49244
3 changed files with 50 additions and 25 deletions

View File

@@ -53,7 +53,7 @@ func makeConfigMap(rf *resource.Factory, name, behavior string, hashValue *strin
return r
}
func makeConfigMapOptions(rf *resource.Factory, name, behavior string, disableHash bool) *resource.Resource {
func makeConfigMapOptions(rf *resource.Factory, name, behavior string, disableHash bool) (*resource.Resource, error) {
return rf.FromMapAndOption(map[string]interface{}{
"apiVersion": "v1",
"kind": "ConfigMap",
@@ -89,7 +89,11 @@ func TestUpdateResourceOptions(t *testing.T) {
name := fmt.Sprintf("test%d", i)
err := in.Append(makeConfigMap(rf, name, c.behavior, c.hashValue))
require.NoError(t, err)
err = expected.Append(makeConfigMapOptions(rf, name, c.behavior, !c.needsHash))
config, err := makeConfigMapOptions(rf, name, c.behavior, !c.needsHash)
if err != nil {
t.Errorf("expected new instance with an options but got error: %v", err)
}
err = expected.Append(config)
require.NoError(t, err)
}
actual, err := UpdateResourceOptions(in)