Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Dec 13, 2024
1 parent ab015e8 commit f673c18
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@
}

{{ end -}}

///////////////////////////////
// Attribute presence checks //
///////////////////////////////

{{ range .Attributes -}}
func ({{ $assertVar }} *{{ $assertName }}) Has{{ SnakeCaseToCamel .Name }}NotEmpty() *{{ $assertName }} {
{{ $assertVar }}.AddAssertion(assert.ValuePresent("{{ .Name }}"))
return {{ $assertVar }}
}

{{ end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ func MapToResourceShowOutputAssertion(field genhelpers.Field) ResourceShowOutput
var assertionCreator string
switch {
case concreteTypeWithoutPtr == "bool":
assertionCreator = "ResourceShowOutputBoolValueSet"
assertionCreator = "ResourceShowOutputBoolValue"
case concreteTypeWithoutPtr == "int":
assertionCreator = "ResourceShowOutputIntValueSet"
assertionCreator = "ResourceShowOutputIntValue"
case concreteTypeWithoutPtr == "float64":
assertionCreator = "ResourceShowOutputFloatValueSet"
assertionCreator = "ResourceShowOutputFloatValue"
case concreteTypeWithoutPtr == "string":
assertionCreator = "ResourceShowOutputValueSet"
assertionCreator = "ResourceShowOutputValue"
// TODO [SNOW-1501905]: distinguish between different enum types
case strings.HasPrefix(concreteTypeWithoutPtr, "sdk."):
assertionCreator = "ResourceShowOutputStringUnderlyingValueSet"
assertionCreator = "ResourceShowOutputStringUnderlyingValue"
default:
assertionCreator = "ResourceShowOutputValueSet"
assertionCreator = "ResourceShowOutputValue"
}

// TODO [SNOW-1501905]: handle other mappings if needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,39 @@
{{- $assertName := .Name | printf "%sShowOutputAssert" -}}
{{- $nameLowerCase := FirstLetterLowercase .Name -}}
{{- $assertVar := FirstLetter $nameLowerCase }}

////////////////////////////
// Attribute value checks //
////////////////////////////

{{ range .Attributes -}}
func ({{ $assertVar }} *{{ $assertName }}) Has{{ .Name }}(expected {{ .ConcreteType }}) *{{ $assertName }} {
{{ $assertVar }}.AddAssertion(assert.{{ .AssertionCreator }}("{{ SnakeCase .Name }}", {{ RunMapper .Mapper "expected" }}))
{{ $assertVar }}.AddAssertion(assert.{{ .AssertionCreator }}Set("{{ SnakeCase .Name }}", {{ RunMapper .Mapper "expected" }}))
return {{ $assertVar }}
}

{{ end -}}

////////////////////////////
// Attribute empty checks //
////////////////////////////

{{ range .Attributes -}}
func ({{ $assertVar }} *{{ $assertName }}) HasNo{{ .Name }}() *{{ $assertName }} {
{{ $assertVar }}.AddAssertion(assert.{{ .AssertionCreator }}NotSet("{{ SnakeCase .Name }}"))
return {{ $assertVar }}
}

{{ end -}}

///////////////////////////////
// Attribute presence checks //
///////////////////////////////

{{ range .Attributes -}}
func ({{ $assertVar }} *{{ $assertName }}) Has{{ .Name }}NotEmpty() *{{ $assertName }} {
{{ $assertVar }}.AddAssertion(assert.{{ .AssertionCreator }}Present("{{ SnakeCase .Name }}"))
return {{ $assertVar }}
}

{{ end -}}

0 comments on commit f673c18

Please sign in to comment.