Skip to content

Commit

Permalink
Merge pull request #851 from Permify/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
tolgaOzen authored Nov 18, 2023
2 parents fdbe100 + 48d005d commit e2daa05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 0 additions & 6 deletions pkg/schema/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/url"
"os"
"path/filepath"
"regexp"
)

// Type defines an enumeration for different schema types.
Expand Down Expand Up @@ -93,11 +92,6 @@ func isURL(input string) bool {
}

func isFilePath(input string) (bool, error) {
// Regex to validate the path format
if match, _ := regexp.MatchString(`^[a-zA-Z0-9_\- /]+$`, input); !match {
return false, errors.New("path format is not valid")
}

_, err := os.Stat(input)
if err != nil {
if os.IsNotExist(err) {
Expand Down
12 changes: 9 additions & 3 deletions pkg/schema/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var _ = Describe("Loader", func() {
Context("LoadSchema function", func() {
It("should load schema from URL", func() {
loader := NewSchemaLoader()
schema, _ := loader.LoadSchema("https://gist.githubusercontent.com/neo773/d50f089c141bf61776c22157413ddbac/raw/ed2eb12108e49fce11be27d0387b8b01912b9d98/gistfile1.txt")
schema, err := loader.LoadSchema("https://gist.githubusercontent.com/neo773/d50f089c141bf61776c22157413ddbac/raw/ed2eb12108e49fce11be27d0387b8b01912b9d98/gistfile1.txt")
Expect(err).ShouldNot(HaveOccurred())

expectedSchema := `
entity userhttp {}
Expand Down Expand Up @@ -40,7 +42,9 @@ var _ = Describe("Loader", func() {

It("should load schema from file", func() {
loader := NewSchemaLoader()
schema, _ := loader.LoadSchema("./schema.txt")
schema, err := loader.LoadSchema("./schema.txt")
Expect(err).ShouldNot(HaveOccurred())

expectedSchema := `
entity userfs {}
Expand Down Expand Up @@ -69,7 +73,7 @@ var _ = Describe("Loader", func() {

It("should load inline schema", func() {
loader := NewSchemaLoader()
schema, _ := loader.LoadSchema(`entity userinline {}
schema, err := loader.LoadSchema(`entity userinline {}
entity organization {
Expand All @@ -91,6 +95,8 @@ var _ = Describe("Loader", func() {
action edit = parent.member not owner
}`)

Expect(err).ShouldNot(HaveOccurred())

expectedSchema := `
entity userinline {}
Expand Down

0 comments on commit e2daa05

Please sign in to comment.