Skip to content

Commit e20ac23

Browse files
authored
config: Add basic fuzzing for config / overrides (#1500)
* config: Add basic fuzzing for config / overrides * build: Upgrade GitHub actions to Go 1.18
1 parent 0a71841 commit e20ac23

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- uses: actions/setup-go@v2
3636
with:
37-
go-version: '1.17'
37+
go-version: '1.18'
3838

3939
- name: test ./...
4040
run: go test --tags=examples ./...

internal/config/config_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ func TestBadConfigs(t *testing.T) {
6464
}
6565
}
6666

67+
const validConfigOne = `{
68+
"version": "1"
69+
"packages": []
70+
}`
71+
72+
func FuzzConfig(f *testing.F) {
73+
f.Add(validConfigOne)
74+
f.Fuzz(func(t *testing.T, orig string) {
75+
ParseConfig(strings.NewReader(orig))
76+
})
77+
}
78+
6779
func TestInvalidConfig(t *testing.T) {
6880
err := Validate(&Config{
6981
SQL: []SQL{{
@@ -163,3 +175,19 @@ func TestTypeOverrides(t *testing.T) {
163175
})
164176
}
165177
}
178+
179+
func FuzzOverride(f *testing.F) {
180+
for _, spec := range []string{
181+
"string",
182+
"github.com/gofrs/uuid.UUID",
183+
"github.com/segmentio/ksuid.KSUID",
184+
} {
185+
f.Add(spec)
186+
}
187+
f.Fuzz(func(t *testing.T, s string) {
188+
o := Override{
189+
GoType: GoType{Spec: s},
190+
}
191+
o.Parse()
192+
})
193+
}

0 commit comments

Comments
 (0)