Skip to content

Commit 9e095f9

Browse files
committed
increase codecov
1 parent 15ce5a5 commit 9e095f9

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

rpc/v10/response_flags_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,57 @@ func TestResponseFlags_UnmarshalJSON(t *testing.T) {
5656
})
5757
}
5858
}
59+
60+
func TestSubscriptionTags_UnmarshalJSON(t *testing.T) {
61+
t.Parallel()
62+
63+
tests := []struct {
64+
name string
65+
json string
66+
expected rpcv10.SubscriptionTags
67+
expectedError string
68+
}{
69+
{
70+
name: "empty array",
71+
json: `[]`,
72+
expected: rpcv10.SubscriptionTags{IncludeProofFacts: false},
73+
},
74+
{
75+
name: "array with INCLUDE_PROOF_FACTS",
76+
json: `["INCLUDE_PROOF_FACTS"]`,
77+
expected: rpcv10.SubscriptionTags{IncludeProofFacts: true},
78+
},
79+
{
80+
name: "array with unknown flag and valid flag",
81+
json: `["INCLUDE_PROOF_FACTS", "UNKNOWN_FLAG"]`,
82+
expectedError: "unknown flag: UNKNOWN_FLAG",
83+
},
84+
{
85+
name: "case sensitive",
86+
json: `["include_proof_facts"]`,
87+
expectedError: "unknown flag: include_proof_facts",
88+
},
89+
{
90+
name: "invalid JSON",
91+
json: `{"not": "an array"}`,
92+
expectedError: "cannot unmarshal",
93+
},
94+
}
95+
96+
for _, tt := range tests {
97+
t.Run(tt.name, func(t *testing.T) {
98+
t.Parallel()
99+
var tags rpcv10.SubscriptionTags
100+
err := json.Unmarshal([]byte(tt.json), &tags)
101+
102+
if tt.expectedError != "" {
103+
require.Error(t, err)
104+
require.Contains(t, err.Error(), tt.expectedError)
105+
return
106+
}
107+
108+
require.NoError(t, err)
109+
require.Equal(t, tt.expected, tags)
110+
})
111+
}
112+
}

0 commit comments

Comments
 (0)