We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d28f8fa commit f48a893Copy full SHA for f48a893
3 files changed
dgraph/cmd/dgraphimport/import_client.go
@@ -25,6 +25,10 @@ import (
25
26
// newClient creates a new import client with the specified endpoint and gRPC options.
27
func newClient(connectionString string) (api.DgraphClient, error) {
28
+ if connectionString == "" {
29
+ return nil, fmt.Errorf("connection string cannot be empty")
30
+ }
31
+
32
dg, err := dgo.Open(connectionString)
33
if err != nil {
34
return nil, fmt.Errorf("failed to connect to endpoint [%s]: %w", connectionString, err)
@@ -35,6 +39,10 @@ func newClient(connectionString string) (api.DgraphClient, error) {
35
39
}
36
40
37
41
func Import(ctx context.Context, connectionString string, bulkOutDir string) error {
42
+ if bulkOutDir == "" {
43
+ return fmt.Errorf("bulk output directory cannot be empty")
44
45
38
46
dg, err := newClient(connectionString)
47
48
return err
dgraph/cmd/dgraphimport/import_test.go
@@ -62,6 +62,18 @@ const expectedSchema = `{
62
]
63
}`
64
65
+func TestEmptyConnStr(t *testing.T) {
66
+ err := Import(context.Background(), "", "/tmp")
67
+ require.Error(t, err)
68
+ require.ErrorContains(t, err, "connection string cannot be empty")
69
+}
70
71
+func TestEmptyBulkOutDir(t *testing.T) {
72
+ err := Import(context.Background(), "dgraph://localhost:9080", "")
73
74
+ require.ErrorContains(t, err, "bulk output directory cannot be empty")
75
76
77
func TestDrainModeAfterStartSnapshotStream(t *testing.T) {
78
t.Skip("Skipping... sometimes the query for schema succeeds even when the server is in draining mode")
79
dgraph/cmd/dgraphimport/run.go
@@ -36,12 +36,11 @@ func init() {
flag.StringP("files", "f", "", "Location of *.rdf(.gz) or *.json(.gz) file(s) to load.")
flag.StringP("snapshot-dir", "p", "", "Location of p directory")
flag.StringP("schema", "s", "", "Location of DQL schema file.")
- flag.StringP("graphql_schema", "g", "", "Location of the GraphQL schema file.")
- flag.StringP("graphql-schema", "", "", "Location of the GraphQL schema file.")
+ flag.StringP("graphql-schema", "g", "", "Location of the GraphQL schema file.")
flag.String("format", "", "Specify file format (rdf or json)")
flag.Bool("drop-all", false, "Drops all the existing data in the cluster before importing data into Dgraph.")
flag.Bool("drop-all-confirm", false, "Confirm drop-all operation.")
- flag.StringP("conn-str", "c", "", "Dgraph connection string.")
+ flag.StringP("conn-str", "c", "dgraph://localhost:9080", "Dgraph connection string.")
func run() {
0 commit comments