MCPcopy
hub / github.com/dgraph-io/dgraph / initTestExport

Function initTestExport

worker/export_test.go:124–159  ·  view source on GitHub ↗
(t *testing.T, schemaStr string)

Source from the content-addressed store, hash-verified

122}
123
124func initTestExport(t *testing.T, schemaStr string) {
125 require.NoError(t, schema.ParseBytes([]byte(schemaStr), 1))
126
127 val, err := proto.Marshal(&pb.SchemaUpdate{ValueType: pb.Posting_UID})
128 require.NoError(t, err)
129
130 txn := pstore.NewTransactionAt(math.MaxUint64, true)
131 require.NoError(t, txn.Set(testutil.RootNsSchemaKey("friend"), val))
132 // Schema is always written at timestamp 1
133 require.NoError(t, txn.CommitAt(1, nil))
134
135 require.NoError(t, err)
136 val, err = proto.Marshal(&pb.SchemaUpdate{ValueType: pb.Posting_UID})
137 require.NoError(t, err)
138
139 txn = pstore.NewTransactionAt(math.MaxUint64, true)
140 require.NoError(t, txn.Set(testutil.RootNsSchemaKey("http://www.w3.org/2000/01/rdf-schema#range"), val))
141 require.NoError(t, txn.Set(testutil.RootNsSchemaKey("friend_not_served"), val))
142 require.NoError(t, txn.Set(testutil.RootNsSchemaKey("age"), val))
143 require.NoError(t, txn.CommitAt(1, nil))
144
145 val, err = proto.Marshal(personType)
146 require.NoError(t, err)
147
148 txn = pstore.NewTransactionAt(math.MaxUint64, true)
149 require.NoError(t, txn.Set(testutil.RootNsTypeKey("Person"), val))
150 require.NoError(t, txn.CommitAt(1, nil))
151
152 populateGraphExport(t)
153
154 // Drop age predicate after populating DB.
155 // age should not exist in the exported schema.
156 txn = pstore.NewTransactionAt(math.MaxUint64, true)
157 require.NoError(t, txn.Delete(testutil.RootNsSchemaKey("age")))
158 require.NoError(t, txn.CommitAt(1, nil))
159}
160
161func getExportFileList(t *testing.T, bdir string) (dataFiles, schemaFiles, gqlSchema []string) {
162 searchDir := bdir

Callers 2

TestExportRdfFunction · 0.85
TestExportJsonFunction · 0.85

Calls 6

ParseBytesFunction · 0.92
RootNsSchemaKeyFunction · 0.92
RootNsTypeKeyFunction · 0.92
populateGraphExportFunction · 0.85
SetMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected