Skip to content

Commit

Permalink
cmd/otk-resolve-ostree-commit: repeat tests with commit ID in input
Browse files Browse the repository at this point in the history
When a commit ID is used in place of the ref, the resolver returns the
input commit ID as both the ref and the checksum.
No request goes to the server for this call.
  • Loading branch information
achilleas-k committed Sep 16, 2024
1 parent 1ef5ab1 commit fe3d728
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cmd/otk-resolve-ostree-commit/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,31 @@ func TestResolver(t *testing.T) {
assert.Equal(expOutput, output)
}

// repeat test but use the commit ID in the request directly (no ref resolve)
for _, id := range commitMap {
inputReq, err := json.Marshal(map[string]map[string]string{
"tree": {
"url": url,
"ref": id,
},
})
require.NoError(err)

inpBuf := bytes.NewBuffer(inputReq)
outBuf := &bytes.Buffer{}

assert.NoError(resolver.Run(inpBuf, outBuf))

var output map[string]map[string]string
require.NoError(json.Unmarshal(outBuf.Bytes(), &output))

expOutput := map[string]map[string]string{
"tree": {
"url": url,
"ref": id,
"checksum": id,
},
}
assert.Equal(expOutput, output)
}
}

0 comments on commit fe3d728

Please sign in to comment.