facd64a14b
* first pass use tests/sdk-tests/run-tests.sh in github action * - -> _ * diagnostic env step * diagnostic env step * diagnostic env step does not support cwd * checkout not preserved between actions * ./ missing * start built containers * missing unmarshalling of content bytes before encoding and generation of CID * unchecked error complaint from linter * golang linting is really picky * utils/json test for comparing known, but deprecated method to new implementation * try curl (retval 0) instead of wget (retval 8) for 404 that is returned * missing curl for health check * use feature branch for laconic-sdk... UNDO THIS LATER * checkout is done from inside of container, rather than copied in from filesystem. checking out dev branch for now * docker network inspect for diagnostic * docker network inspect for diagnostic missing arg * listen on 0.0.0.0 specfically * trying localhost * try host mode network * host mode breaks name resolution of containers * manual service check in laconicd container for diagnostic * revert ListenAndServe * sleep and docker logs... appears endpoint is not coming up maybe? * disable fail_ci on codecov error... it is unstable * turn codecov back to fail on error true to avoid invisible failure. * Cleanup for whitespace and require.NoError in test * new json util test, turning off codecov fails CI, and gitignore for test artifacts
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package utils
|
|
|
|
import (
|
|
"github.com/stretchr/testify/require"
|
|
"testing"
|
|
)
|
|
|
|
func TestAndValidateCIDGeneration(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
content string
|
|
expected string
|
|
}{
|
|
// empty string and empty json blows up
|
|
// {
|
|
// "empty string", "", "bafyreiengp2sbi6ez34a2jctv34bwyjl7yoliteleaswgcwtqzrhmpyt2m",
|
|
// },
|
|
// {
|
|
// "empty json", "{}", "bafyreihpfkdvib5muloxlj5b3tgdwibjdcu3zdsuhyft33z7gtgnlzlkpm",
|
|
// },
|
|
|
|
{
|
|
"test record", "{\"build_artifact_cid\":\"QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9\",\"repo_registration_record_cid\":\"QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D\",\"tls_cert_cid\":\"QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\",\"type\":\"WebsiteRegistrationRecord\",\"url\":\"https://cerc.io\",\"version\":\"0.0.1\"}",
|
|
"bafyreiek4hnoqmits66bjyxswapplweuoqe4en2ux6u772o4y3askpd3ny",
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
deprecatedAndCorrect, _ := CIDFromJSONBytes([]byte(tc.content))
|
|
newImpl, err := CIDFromJSONBytesUsingIpldPrime([]byte(tc.content))
|
|
require.NoError(t, err)
|
|
require.Equal(t, deprecatedAndCorrect, newImpl, tc.name)
|
|
require.Equal(t, tc.expected, newImpl)
|
|
}
|
|
}
|