Add test case
Some checks failed
Build / cleanup-runs (pull_request) Successful in 5s
Deploy Contract / cleanup-runs (pull_request) Successful in 6s
Deploy Contract / deploy (pull_request) Failing after 42s
Build / build (pull_request) Successful in 55s
Dependency Review / dependency-review (pull_request) Successful in 53s
CodeQL / Analyze (go) (pull_request) Successful in 1m1s
Pull Request Labeler / triage (pull_request) Successful in 10s
Semgrep / Scan (pull_request) Failing after 10s
Run Gosec / Gosec (pull_request) Successful in 19s
Tests / cleanup-runs (pull_request) Successful in 8s
Lint / Run golangci-lint (pull_request) Successful in 55s
Lint / Run flake8 on python integration tests (pull_request) Failing after 52s
Tests / test-rpc (pull_request) Successful in 50s
Tests / test-importer (pull_request) Successful in 1m48s
Tests / test-unit-cover (pull_request) Successful in 1m56s
Tests / sdk_tests (pull_request) Failing after 2m17s
Some checks failed
Build / cleanup-runs (pull_request) Successful in 5s
Deploy Contract / cleanup-runs (pull_request) Successful in 6s
Deploy Contract / deploy (pull_request) Failing after 42s
Build / build (pull_request) Successful in 55s
Dependency Review / dependency-review (pull_request) Successful in 53s
CodeQL / Analyze (go) (pull_request) Successful in 1m1s
Pull Request Labeler / triage (pull_request) Successful in 10s
Semgrep / Scan (pull_request) Failing after 10s
Run Gosec / Gosec (pull_request) Successful in 19s
Tests / cleanup-runs (pull_request) Successful in 8s
Lint / Run golangci-lint (pull_request) Successful in 55s
Lint / Run flake8 on python integration tests (pull_request) Failing after 52s
Tests / test-rpc (pull_request) Successful in 50s
Tests / test-importer (pull_request) Successful in 1m48s
Tests / test-unit-cover (pull_request) Successful in 1m56s
Tests / sdk_tests (pull_request) Failing after 2m17s
This commit is contained in:
parent
911f4ec252
commit
a310c375ab
7
x/registry/helpers/examples/general_record_example.yml
Normal file
7
x/registry/helpers/examples/general_record_example.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
record:
|
||||||
|
type: GeneralRecord
|
||||||
|
name: foo
|
||||||
|
version: 1.0.0
|
||||||
|
tags:
|
||||||
|
- tagA
|
||||||
|
- tagB
|
@ -3,12 +3,12 @@ package keeper_test
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
||||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||||
"github.com/cerc-io/laconicd/x/registry/keeper"
|
"github.com/cerc-io/laconicd/x/registry/keeper"
|
||||||
registrytypes "github.com/cerc-io/laconicd/x/registry/types"
|
registrytypes "github.com/cerc-io/laconicd/x/registry/types"
|
||||||
|
"os"
|
||||||
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (suite *KeeperTestSuite) TestGrpcQueryParams() {
|
func (suite *KeeperTestSuite) TestGrpcQueryParams() {
|
||||||
@ -39,6 +39,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
examples := []string{
|
examples := []string{
|
||||||
"/../helpers/examples/service_provider_example.yml",
|
"/../helpers/examples/service_provider_example.yml",
|
||||||
"/../helpers/examples/website_registration_example.yml",
|
"/../helpers/examples/website_registration_example.yml",
|
||||||
|
"/../helpers/examples/general_record_example.yml",
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg string
|
msg string
|
||||||
@ -59,7 +60,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
®istrytypes.QueryListRecordsRequest{},
|
®istrytypes.QueryListRecordsRequest{},
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
2,
|
3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Filter with type",
|
"Filter with type",
|
||||||
@ -79,6 +80,42 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
false,
|
false,
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Filter with tag (extant) (https://git.vdb.to/cerc-io/laconicd/issues/129)",
|
||||||
|
®istrytypes.QueryListRecordsRequest{
|
||||||
|
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||||
|
{
|
||||||
|
Key: "tags",
|
||||||
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||||
|
Type: "string",
|
||||||
|
String_: "tagA",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
All: true,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Filter with tag (non-existent) (https://git.vdb.to/cerc-io/laconicd/issues/129)",
|
||||||
|
®istrytypes.QueryListRecordsRequest{
|
||||||
|
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||||
|
{
|
||||||
|
Key: "tags",
|
||||||
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||||
|
Type: "string",
|
||||||
|
String_: "NOEXIST",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
All: true,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
0,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)",
|
"Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)",
|
||||||
®istrytypes.QueryListRecordsRequest{
|
®istrytypes.QueryListRecordsRequest{
|
||||||
@ -151,10 +188,25 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
recAttr := helpers.UnMarshalMapFromJSONBytes(bz)
|
recAttr := helpers.UnMarshalMapFromJSONBytes(bz)
|
||||||
for _, attr := range test.req.GetAttributes() {
|
for _, attr := range test.req.GetAttributes() {
|
||||||
if attr.Key[:4] == "x500" {
|
av := keeper.GetAttributeValue(attr.Value)
|
||||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
if nil != av && nil != recAttr[attr.Key] &&
|
||||||
|
reflect.Slice == reflect.TypeOf(recAttr[attr.Key]).Kind() &&
|
||||||
|
reflect.Slice != reflect.TypeOf(av).Kind() {
|
||||||
|
found := false
|
||||||
|
allValues := recAttr[attr.Key].([]interface{})
|
||||||
|
for i := range allValues {
|
||||||
|
if av == allValues[i] {
|
||||||
|
fmt.Printf("Found %s in %s", allValues[i], recAttr[attr.Key])
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sr.Equal(true, found, fmt.Sprintf("Unable to find %s in %s", av, recAttr[attr.Key]))
|
||||||
} else {
|
} else {
|
||||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr[attr.Key])
|
if attr.Key[:4] == "x500" {
|
||||||
|
sr.Equal(av, recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
||||||
|
} else {
|
||||||
|
sr.Equal(av, recAttr[attr.Key])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user