Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineJac committed Nov 28, 2024
1 parent d814d2f commit c077ab7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 14 additions & 1 deletion tests/integration/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ func Test_Validate_Konnect(t *testing.T) {
additionalArgs: []string{"--konnect-runtime-group-name=default"},
errorExpected: false,
},
{
name: "validate with wrong online list, passed via --online-entities-list cli flag",
stateFile: "testdata/validate/kong3x.yaml",
additionalArgs: []string{"--online-entities-list=services,Routes,Plugins"},
errorExpected: true,
errorString: "invalid value 'services' for --check-online-plugins-only; it should be a valid Kong entity",
},
{
name: "validate with correct online list, passed via --online-entities-list cli flag",
stateFile: "testdata/validate/kong3x.yaml",
additionalArgs: []string{"--online-entities-list=Services,Routes,Plugins"},
errorExpected: false,
},
}

for _, tc := range tests {
Expand Down Expand Up @@ -136,7 +149,7 @@ func Test_Validate_File(t *testing.T) {
{
name: "file validate with --online-entities-list",
stateFile: "testdata/validate/kong3x.yaml",
additionalArgs: []string{"--online-entities-list Service,Routes"},
additionalArgs: []string{"--online-entities-list=Services,Routes,Plugins"},
},
}

Expand Down
4 changes: 0 additions & 4 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"reflect"
"sync"
"log"

"github.com/blang/semver/v4"
"github.com/kong/deck/utils"
Expand Down Expand Up @@ -175,9 +174,6 @@ func (v *Validator) Validate(formatVersion semver.Version) []error {

// Validate each entity using the filtered entityMap
for fieldName, entityName := range filteredEntityMap {
// Log the fieldName and entityName
log.Printf("Validating field: %s, entity: %s", fieldName, entityName)

// Use reflection to get the value of the field from v.state
valueOfState := reflect.ValueOf(v.state)
if valueOfState.Kind() == reflect.Ptr {
Expand Down

0 comments on commit c077ab7

Please sign in to comment.