Skip to content

Commit

Permalink
fix: crash with unset source
Browse files Browse the repository at this point in the history
  • Loading branch information
veezhang committed Sep 7, 2023
1 parent d53e628 commit fb080cd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ tags:
- name: Person
id:
type: "STRING"
concatItems: 0
concatItems:
- "abc"
- 1
function: hash
Expand Down
1 change: 1 addition & 0 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var (
ErrUnsupportedClientVersion = stderrors.New("unsupported client version")
ErrNoAddresses = stderrors.New("no addresses")
ErrInvalidAddress = stderrors.New("invalid address")
ErrUnsetSource = stderrors.New("unset source")
ErrInvalidIndex = stderrors.New("invalid index")
ErrNoSpaceName = stderrors.New("no space name")
ErrNoGraphName = stderrors.New("no graph name")
Expand Down
5 changes: 4 additions & 1 deletion pkg/source/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package source

import (
"io"

"github.com/vesoft-inc/nebula-importer/v4/pkg/errors"
)

type (
Expand Down Expand Up @@ -39,7 +41,8 @@ func New(c *Config) (Source, error) {
return newHDFSSource(c), nil
case c.GCS != nil:
return newGCSSource(c), nil
default:
case c.Local != nil:
return newLocalSource(c), nil
}
return nil, errors.ErrUnsetSource
}
9 changes: 9 additions & 0 deletions pkg/source/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ package source
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/vesoft-inc/nebula-importer/v4/pkg/errors"
)

var _ = Describe("Source", func() {
It("ErrNoSource", func() {
c := Config{}
s, err := New(&c)
Expect(err).To(HaveOccurred())
Expect(err).To(Equal(errors.ErrUnsetSource))
Expect(s).To(BeNil())
})

It("S3", func() {
c := Config{
S3: &S3Config{
Expand Down

0 comments on commit fb080cd

Please sign in to comment.