Skip to content

Commit

Permalink
fix(engine): minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen committed Dec 28, 2023
1 parent ed187c0 commit 9589a95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 0 additions & 2 deletions engine/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ func (e *QueryEngine) GetEncodedDatasources() (string, error) {
return "", fmt.Errorf("marshal datasources: %w", err)
}

log.Printf("overriding datasources raw: %s", raw)

datasourcesBase64 := base64.URLEncoding.EncodeToString(raw)

return datasourcesBase64, nil
Expand Down
2 changes: 0 additions & 2 deletions generator/templates/models.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
{{ range $field := $model.Fields }}
{{- if not $field.Kind.IsRelation -}}
{{- if $field.IsRequired }}
// GoCase {{ $field.Name.GoCase }}
// GoLowerCase {{ $field.Name.GoLowerCase }}
{{ $field.Name.GoCase }} {{ if $field.IsList }}[]{{ end }}{{ $field.Type.Value }} {{ $field.Name.Tag $field.IsRequired }}
{{- else }}
{{ $field.Name.GoCase }} {{ if $field.IsList }}[]{{ else }}*{{ end }}{{ $field.Type.Value }} {{ $field.Name.Tag $field.IsRequired }}
Expand Down
28 changes: 24 additions & 4 deletions helpers/gocase/gocase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,16 @@ func TestConverter_Revert(t *testing.T) {
}
}

// FuzzReverse runs a Fuzzing test to check if the strings
// FuzzReverseUpper runs a Fuzzing test to check if the strings
// before and after `To` and `Revert` match.
// Note that there may be cases where the strings before and after
// the `To` and `Revert` do not match for certain inputs.
//
// ```cmd
// go test -fuzz=Fuzz
// ```
func FuzzReverse(f *testing.F) {
f.Skip()
testcases := []string{"jsonFile", "IpAddress", "defaultDnsServer"}
func FuzzReverseUpper(f *testing.F) {
testcases := []string{"JsonFile", "IpAddress", "DefaultDnsServer"}
for _, tc := range testcases {
f.Add(tc)
}
Expand All @@ -161,6 +160,27 @@ func FuzzReverse(f *testing.F) {
})
}

// FuzzReverseLower runs a Fuzzing test to check if the strings
// before and after `To` and `Revert` match.
// Note that there may be cases where the strings before and after
// the `To` and `Revert` do not match for certain inputs.
func FuzzReverseLower(f *testing.F) {
testcases := []string{"jsonFile", "ipAddress", "defaultDnsServer"}
for _, tc := range testcases {
f.Add(tc)
}
f.Fuzz(func(t *testing.T, orig string) {
to := gocase.ToLower(orig)
rev := gocase.Revert(to)
if !ignoreInput(orig) && orig != rev {
t.Errorf("before: %q, after: %q", orig, rev)
}
if utf8.ValidString(orig) && !utf8.ValidString(rev) {
t.Errorf("To or Revert produced invalid UTF-8 string %q", rev)
}
})
}

func ignoreInput(in string) bool {

for _, s := range gocase.DefaultInitialisms {
Expand Down

0 comments on commit 9589a95

Please sign in to comment.