Skip to content

Commit

Permalink
update function names for crossplane
Browse files Browse the repository at this point in the history
  • Loading branch information
salonichf5 committed Dec 19, 2024
1 parent ca42375 commit f5c5d87
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tests/framework/crossplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ type ExpectedNginxField struct {
// ValidateNginxFieldExists accepts the nginx config and the configuration for the expected field,
// and returns whether or not that field exists where it should.
func ValidateNginxFieldExists(conf *Payload, expFieldCfg ExpectedNginxField) error {
var directiveFoundInServer, directiveFoundInUpstream bool

b, err := json.Marshal(conf)
if err != nil {
return fmt.Errorf("error marshaling nginx config: %w", err)
Expand All @@ -61,15 +59,11 @@ func ValidateNginxFieldExists(conf *Payload, expFieldCfg ExpectedNginxField) err
continue
}

directiveFoundInServer = validateServerBlockDirectives(expFieldCfg, *directive)

directiveFoundInUpstream = validateUpstreamDirectives(expFieldCfg, *directive)

if len(expFieldCfg.Server) > 0 && directiveFoundInServer {
if len(expFieldCfg.Server) > 0 && fieldExistsInServer(expFieldCfg, *directive) {
return nil
}

if len(expFieldCfg.Upstream) > 0 && directiveFoundInUpstream {
if len(expFieldCfg.Upstream) > 0 && fieldExistsInUpstream(expFieldCfg, *directive) {
return nil
}
}
Expand All @@ -78,7 +72,7 @@ func ValidateNginxFieldExists(conf *Payload, expFieldCfg ExpectedNginxField) err
return fmt.Errorf("directive %s not found in: nginx config %s", expFieldCfg.Directive, string(b))
}

func validateServerBlockDirectives(
func fieldExistsInServer(
expFieldCfg ExpectedNginxField,
directive Directive,
) bool {
Expand All @@ -96,7 +90,7 @@ func validateServerBlockDirectives(
return fieldFound
}

func validateUpstreamDirectives(
func fieldExistsInUpstream(
expFieldCfg ExpectedNginxField,
directive Directive,
) bool {
Expand Down

0 comments on commit f5c5d87

Please sign in to comment.