Skip to content

Commit

Permalink
Add additional test case for validator
Browse files Browse the repository at this point in the history
  • Loading branch information
pkosiec committed Aug 10, 2021
1 parent 7342ccf commit 0dcf6ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 4 additions & 3 deletions internal/cli/validate/validate_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package validate_test

import (
"capact.io/capact/internal/cli/validate"
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io/ioutil"
"path"
"strings"
"testing"

"capact.io/capact/internal/cli/validate"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestValidation_Run(t *testing.T) {
Expand Down
16 changes: 13 additions & 3 deletions pkg/sdk/manifest/fsvalidator_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package manifest_test

import (
"capact.io/capact/pkg/hub/api/graphql/public"
"context"
"github.com/pkg/errors"
"testing"

graphql "capact.io/capact/pkg/hub/api/graphql/public"
"github.com/pkg/errors"

"capact.io/capact/internal/cli/schema"
"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -90,6 +91,16 @@ func TestFilesystemValidator_ValidateFile(t *testing.T) {
sampleAttr: false,
}, nil),
},
"Error from Hub": {
manifestPath: "testdata/valid-interface.yaml",
expectedValidationErrorMsgs: []string{
"while running validator RemoteInterfaceValidator: while checking if manifest revisions exist: test error",
},
hubCli: fixHub(t, map[graphql.ManifestReference]bool{
manifestRef("cap.type.productivity.mattermost.config"): true,
manifestRef("cap.type.productivity.mattermost.install-input"): true,
}, errors.New("test error")),
},
"Cannot load file": {
manifestPath: "testdata/no-file.yaml",
expectedGeneralErrMsg: "open testdata/no-file.yaml: no such file or directory",
Expand Down Expand Up @@ -163,7 +174,6 @@ func fixHub(t *testing.T, result map[graphql.ManifestReference]bool, err error)
},
}
return hub

}

func manifestRef(path string) graphql.ManifestReference {
Expand Down

0 comments on commit 0dcf6ae

Please sign in to comment.