quintush / helm-unittest

BDD styled unit test framework for Kubernetes Helm charts as a Helm plugin.
MIT License
344 stars 69 forks source link

Pre-process rendered data before comparison. #126

Closed wenhulove333 closed 3 years ago

wenhulove333 commented 3 years ago

For gopkg.in/yaml.v2, if there are spaces before break, it will take all input as plain string even special characters in yaml.

For example, following string will be treated as plain string because of type: \"slowpath\" \n. "dpdk-host-bind: \"true\"\niface-info:\n eth0:\n role: \"internal\"\n type: \"slowpath\"\n internal:\n role: \"internal\"\n type: \"slowpath\" \n \ tracing:\n mtu: 1500\n role: \"external\"\n type: \"slowpath\"\nvlan-info: \ \n tracing:\n - vlanId: 1916\n vlanName: \"tracingvlan\"\n ipv6RangeStart: \"2a00:8a00:8000:136:10:57:218:8f/122\"\n ipv6RangeEnd: \"2a00:8a00:8000:136:10:57:218:8f/122\"\n \ ipv6Subnet: \"2a00:8a00:8000:136:10:57:217:1a/128\"\n ipv6Role:\n - \"Tracing\"\nip-role:\n internal:\n ipv6:\n - \"internal\""

wenhulove333 commented 3 years ago

@quintush For more readable for multiline yaml format, I made this modification, please review and merge it. Thank you. The related scenario is configmap.

wenhulove333 commented 3 years ago

Any comments about this request.

quintush commented 3 years ago

Thanks for the improvement. I have moved your additional validation to a more central place, so it can also be used in more assertions. Also i added the optional validation to check optional for the carrage return, to ensure testfiles created on windows machine don't have a bad day.