tests/sizes.js: Fix byte array unpacking

Recent GJS changed how byte arrays are unpacked with some assumptions
that they are likely strings. Manually use get_child_value() and
get_byte() to ensure the correct value is parsed when checking the
`ostree.sizes` metadata.

The upstream test is currently passing fine with GJS 1.56.2, but at
Endless we (unfortunately) have a downstream change that adds the object
type as an additional byte in the array. This is parsed incorrectly by
`deep_unpack()`. We can carry this patch downstream, but this change
makes the test more robust regardless.

Closes: #1884
Approved by: cgwalters
This commit is contained in:
Dan Nicholson 2019-07-08 15:08:07 -06:00 committed by Atomic Bot
parent 2312caad76
commit 615861443b

View File

@ -64,10 +64,10 @@ assertEquals(nSizes, 2);
let expectedUncompressedSizes = [12, 18];
let foundExpectedUncompressedSizes = 0;
for (let i = 0; i < nSizes; i++) {
let sizeEntry = sizes.get_child_value(i).deep_unpack();
assertEquals(sizeEntry.length, 34);
let compressedSize = sizeEntry[32];
let uncompressedSize = sizeEntry[33];
let sizeEntry = sizes.get_child_value(i);
assertEquals(sizeEntry.n_children(), 34);
let compressedSize = sizeEntry.get_child_value(32).get_byte();
let uncompressedSize = sizeEntry.get_child_value(33).get_byte();
print("compressed = " + compressedSize);
print("uncompressed = " + uncompressedSize);
for (let j = 0; j < expectedUncompressedSizes.length; j++) {