Skip to content

Commit 73d0e88

Browse files
authored
Fuzz test Thrift to Proto mapper round trips (#1457)
**What changed?** Adds fuzz tests to all thrift->proto->thrift round trip mappers. <!-- Tell your future self why have you made these changes --> **Why?** When mapping from idl to another there are multiple scenarios: 1. neither mapper implements a field 1. the mapper implementations are incompatible 1. both mappers implement a field correctly 1. both mappers implement conversion incorrectly but in a reversible way (e.g they both do a rot13 of an [a-z] string) Our existing tests test for scenarios 2 and 3, but don't test for 1 - if someone adds a new field and omits it from the mappers + the test data, it will never be tested for. This PR adds a fuzz test which randomly assigns data to all fields (including nils), which ensures that unmapped data will be tested for without requiring the developer to check it (and keeps the tests for 2 & 3).
1 parent b6fc775 commit 73d0e88

File tree

4 files changed

+2092
-4
lines changed

4 files changed

+2092
-4
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/gogo/protobuf v1.3.2
99
github.com/golang-jwt/jwt/v5 v5.2.0
1010
github.com/golang/mock v1.5.0
11+
github.com/google/gofuzz v1.0.0
1112
github.com/jonboulle/clockwork v0.4.0
1213
github.com/marusama/semaphore/v2 v2.5.0
1314
github.com/opentracing/opentracing-go v1.1.0

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
9292
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
9393
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
9494
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
95+
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
9596
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
9697
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
9798
github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA=

0 commit comments

Comments
 (0)