Skip to content

Commit 9bada3b

Browse files
authored
test(golang): the repeated-output case in TestValidateRefusals breaks only that rule
The "output twice" case had no Kind, so Validate refused its first Equality under the untyped rule and never reached the second: deleting the "asked for twice" check left every test passing. The case is now typed UInt32, and a second assertion checks that the repetition is what the error names. Addresses PR #1096 review comment 4194355755. Claude-Session: https://claude.ai/code/session_01V3WFXwax4J3uecpFEJ6yHc
1 parent 2082dd7 commit 9bada3b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎languages/golang/internal/record/record_test.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestValidateRefusals(t *testing.T) {
136136
"unknown kind": one(Field{Name: "a", Kind: "integer", Outputs: []Output{Ciphertext}}),
137137
"no output": one(Field{Name: "a"}),
138138
"unknown output": one(Field{Name: "a", Outputs: []Output{"json"}}),
139-
"output twice": one(Field{Name: "a", Outputs: []Output{Equality, Equality}}),
139+
"output twice": one(Field{Name: "a", Kind: UInt32, Outputs: []Output{Equality, Equality}}),
140140
"bad extension part": {Context: []string{"users"}, Extension: []any{1.5}, Fields: []Field{{Name: "a", Outputs: []Output{Ciphertext}}}},
141141
"name is not a label": one(Field{Name: "b64:x", Outputs: []Output{Ciphertext}}),
142142
"indexed and untyped": one(Field{Name: "a", Outputs: []Output{Ciphertext, Equality}}),
@@ -156,6 +156,12 @@ func TestValidateRefusals(t *testing.T) {
156156
if err == nil || !strings.Contains(err.Error(), `field "age"`) || !strings.Contains(err.Error(), "ore term") {
157157
t.Errorf("an indexed untyped field: err = %v, want the field and the term named", err)
158158
}
159+
// A repeated output is refused for the repetition: the field is typed,
160+
// so the untyped rule cannot be what refuses it.
161+
err = one(Field{Name: "a", Kind: UInt32, Outputs: []Output{Equality, Equality}}).Validate()
162+
if err == nil || !strings.Contains(err.Error(), "asked for twice") {
163+
t.Errorf("an output asked for twice: err = %v, want the repeated output named", err)
164+
}
159165
}
160166

161167
func TestParseContext(t *testing.T) {

0 commit comments

Comments
 (0)