Skip to content

Commit

Permalink
feat: add order=unk test
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jun 23, 2023
1 parent 61d6957 commit f39744d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/trustless_gateway_car_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func TestTrustlessCarEntityBytes(t *testing.T) {
RunWithSpecs(t, helpers.StandardCARTestTransforms(t, tests), specs.TrustlessGatewayCAR)
}

func TestTrustlessCarDuplicates(t *testing.T) {
func TestTrustlessCarOrderAndDuplicates(t *testing.T) {
dirWithDuplicateFiles := car.MustOpenUnixfsCar("t0118/dir-with-duplicate-files.car")

tests := SugarTests{
Expand Down Expand Up @@ -646,6 +646,34 @@ func TestTrustlessCarDuplicates(t *testing.T) {
InThatOrder(),
),
},
{
Name: "GET CAR with order=unk of UnixFS Directors",
Hint: `
The response with order=unk MUST contain all the blocks required to construct
the requested CID. However, it can be in any order and duplicates MAY occur.
`,
Request: Request().
Path("/ipfs/{{cid}}", dirWithDuplicateFiles.MustGetCid()).
Header("Accept", "application/vnd.ipld.car; version=1; order=unk"),
Response: Expect().
Status(200).
Headers(
Header("Content-Type").Contains("application/vnd.ipld.car"),
Header("Content-Type").Contains("order="),
).
Body(
IsCar().
IgnoreRoots().
HasBlocks(flattenStrings(t,
dirWithDuplicateFiles.MustGetCid(),
dirWithDuplicateFiles.MustGetCid("ascii.txt"),
dirWithDuplicateFiles.MustGetCid("ascii-copy.txt"),
dirWithDuplicateFiles.MustGetCid("hello.txt"),
dirWithDuplicateFiles.MustGetCid("multiblock.txt"),
dirWithDuplicateFiles.MustGetChildrenCids("multiblock.txt"),
)...),
),
},
}

// TODO: add sub-specification for these tests.
Expand Down

0 comments on commit f39744d

Please sign in to comment.