Skip to content

Commit

Permalink
Structurally compare js objects rather than YAML (#404)
Browse files Browse the repository at this point in the history
* Structurally compare js objects rather than YAML

* Correct the return type in the signature

* Correct the return type in the signature (again)
  • Loading branch information
Bj0rnen authored Sep 28, 2021
1 parent a2dfc8b commit 37e38c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ts/kpt-functions/src/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { Configs, KptFunc } from './types';
import { safeDump } from 'js-yaml';
import { safeDump, safeLoad } from 'js-yaml';

/**
* TestRunner makes it easy to write unit tests for kpt functions.
Expand Down Expand Up @@ -129,12 +129,13 @@ async function testFn(
}
}

function valueOf(configs: Configs): string {
function valueOf(configs: Configs): any {
const output = configs.toResourceList();
return safeDump(output, {
const yaml = safeDump(output, {
indent: 2,
noArrayIndent: true,
skipInvalid: true,
sortKeys: true,
});
return safeLoad(yaml);
}

0 comments on commit 37e38c1

Please sign in to comment.