本文整理汇总了Golang中github.com/attic-labs/noms/go/spec.CreateValueSpecString函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateValueSpecString函数的具体用法?Golang CreateValueSpecString怎么用?Golang CreateValueSpecString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateValueSpecString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestCSVImporterFromBlob
func (s *testSuite) TestCSVImporterFromBlob() {
test := func(pathFlag string) {
defer os.RemoveAll(s.LdbDir)
newDB := func() datas.Database {
cs := chunks.NewLevelDBStore(s.LdbDir, "", 1, false)
return datas.NewDatabase(cs)
}
db := newDB()
rawDS := dataset.NewDataset(db, "raw")
csv := &bytes.Buffer{}
writeCSV(csv)
rawDS.CommitValue(types.NewBlob(csv))
db.Close()
stdout, stderr := s.Run(main, []string{
"--no-progress", "--column-types", "String,Number",
pathFlag, spec.CreateValueSpecString("ldb", s.LdbDir, "raw.value"),
spec.CreateValueSpecString("ldb", s.LdbDir, "csv"),
})
s.Equal("", stdout)
s.Equal("", stderr)
db = newDB()
defer db.Close()
csvDS := dataset.NewDataset(db, "csv")
validateCSV(s, csvDS.HeadValue().(types.List))
}
test("--path")
test("-p")
}
开发者ID:Richardphp,项目名称:noms,代码行数:32,代码来源:importer_test.go
示例2: TestSync
func (s *nomsSyncTestSuite) TestSync() {
source1 := dataset.NewDataset(datas.NewDatabase(chunks.NewLevelDBStore(s.LdbDir, "", 1, false)), "foo")
source1, err := source1.CommitValue(types.Number(42))
s.NoError(err)
source2, err := source1.CommitValue(types.Number(43))
s.NoError(err)
source1HeadRef := source1.Head().Hash()
source2.Database().Close() // Close Database backing both Datasets
sourceSpec := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+source1HeadRef.String())
ldb2dir := path.Join(s.TempDir, "ldb2")
sinkDatasetSpec := spec.CreateValueSpecString("ldb", ldb2dir, "bar")
s.Run(main, []string{"sync", sourceSpec, sinkDatasetSpec})
dest := dataset.NewDataset(datas.NewDatabase(chunks.NewLevelDBStore(ldb2dir, "", 1, false)), "bar")
s.True(types.Number(42).Equals(dest.HeadValue()))
dest.Database().Close()
sourceDataset := spec.CreateValueSpecString("ldb", s.LdbDir, "foo")
s.Run(main, []string{"sync", sourceDataset, sinkDatasetSpec})
dest = dataset.NewDataset(datas.NewDatabase(chunks.NewLevelDBStore(ldb2dir, "", 1, false)), "bar")
s.True(types.Number(43).Equals(dest.HeadValue()))
dest.Database().Close()
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:noms_sync_test.go
示例3: TestNArg
func (s *nomsLogTestSuite) TestNArg() {
str := spec.CreateDatabaseSpecString("ldb", s.LdbDir)
dsName := "nArgTest"
db, err := spec.GetDatabase(str)
s.NoError(err)
ds := dataset.NewDataset(db, dsName)
ds, err = addCommit(ds, "1")
h1 := ds.Head().Hash()
s.NoError(err)
ds, err = addCommit(ds, "2")
s.NoError(err)
h2 := ds.Head().Hash()
ds, err = addCommit(ds, "3")
s.NoError(err)
h3 := ds.Head().Hash()
db.Close()
dsSpec := spec.CreateValueSpecString("ldb", s.LdbDir, dsName)
res, _ := s.Run(main, []string{"log", "-n1", dsSpec})
s.NotContains(res, h1.String())
res, _ = s.Run(main, []string{"log", "-n0", dsSpec})
s.Contains(res, h3.String())
s.Contains(res, h2.String())
s.Contains(res, h1.String())
vSpec := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+h3.String())
res, _ = s.Run(main, []string{"log", "-n1", vSpec})
s.NotContains(res, h1.String())
res, _ = s.Run(main, []string{"log", "-n0", vSpec})
s.Contains(res, h3.String())
s.Contains(res, h2.String())
s.Contains(res, h1.String())
}
开发者ID:Richardphp,项目名称:noms,代码行数:35,代码来源:noms_log_test.go
示例4: TestNomsShow
func (s *nomsShowTestSuite) TestNomsShow() {
datasetName := "dsTest"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
s1 := types.String("test string")
r := writeTestData(str, s1)
res, _ := s.Run(main, []string{"show", str})
s.Equal(res1, res)
str1 := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+r.TargetHash().String())
res, _ = s.Run(main, []string{"show", str1})
s.Equal(res2, res)
list := types.NewList(types.String("elem1"), types.Number(2), types.String("elem3"))
r = writeTestData(str, list)
res, _ = s.Run(main, []string{"show", str})
test.EqualsIgnoreHashes(s.T(), res3, res)
str1 = spec.CreateValueSpecString("ldb", s.LdbDir, "#"+r.TargetHash().String())
res, _ = s.Run(main, []string{"show", str1})
s.Equal(res4, res)
_ = writeTestData(str, s1)
res, _ = s.Run(main, []string{"show", str})
test.EqualsIgnoreHashes(s.T(), res5, res)
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:noms_show_test.go
示例5: TestNomsGraph2
func (s *nomsLogTestSuite) TestNomsGraph2() {
str := spec.CreateDatabaseSpecString("ldb", s.LdbDir)
db, err := spec.GetDatabase(str)
s.NoError(err)
ba := dataset.NewDataset(db, "ba")
ba, err = addCommit(ba, "1")
s.NoError(err)
bb := dataset.NewDataset(db, "bb")
bb, err = addCommit(bb, "10")
s.NoError(err)
bc := dataset.NewDataset(db, "bc")
bc, err = addCommit(bc, "100")
s.NoError(err)
ba, err = mergeDatasets(ba, bb, "11")
s.NoError(err)
_, err = mergeDatasets(ba, bc, "101")
s.NoError(err)
db.Close()
res, _ := s.Run(main, []string{"log", "--graph", "--show-value=true", spec.CreateValueSpecString("ldb", s.LdbDir, "ba")})
s.Equal(graphRes2, res)
res, _ = s.Run(main, []string{"log", "--graph", "--show-value=false", spec.CreateValueSpecString("ldb", s.LdbDir, "ba")})
s.Equal(diffRes2, res)
}
开发者ID:Richardphp,项目名称:noms,代码行数:31,代码来源:noms_log_test.go
示例6: TestNomsGraph1
func (s *nomsLogTestSuite) TestNomsGraph1() {
str := spec.CreateDatabaseSpecString("ldb", s.LdbDir)
db, err := spec.GetDatabase(str)
s.NoError(err)
b1 := dataset.NewDataset(db, "b1")
b1, err = addCommit(b1, "1")
s.NoError(err)
b1, err = addCommit(b1, "2")
s.NoError(err)
b1, err = addCommit(b1, "3")
s.NoError(err)
b2 := dataset.NewDataset(db, "b2")
b2, err = addBranchedDataset(b2, b1, "3.1")
s.NoError(err)
b1, err = addCommit(b1, "3.2")
s.NoError(err)
b1, err = addCommit(b1, "3.6")
s.NoError(err)
b3 := dataset.NewDataset(db, "b3")
b3, err = addBranchedDataset(b3, b2, "3.1.3")
s.NoError(err)
b3, err = addCommit(b3, "3.1.5")
s.NoError(err)
b3, err = addCommit(b3, "3.1.7")
s.NoError(err)
b2, err = mergeDatasets(b2, b3, "3.5")
s.NoError(err)
b2, err = addCommit(b2, "3.7")
s.NoError(err)
b1, err = mergeDatasets(b1, b2, "4")
s.NoError(err)
b1, err = addCommit(b1, "5")
s.NoError(err)
b1, err = addCommit(b1, "6")
s.NoError(err)
b1, err = addCommit(b1, "7")
s.NoError(err)
b1.Database().Close()
res, _ := s.Run(main, []string{"log", "--graph", "--show-value=true", spec.CreateValueSpecString("ldb", s.LdbDir, "b1")})
s.Equal(graphRes1, res)
res, _ = s.Run(main, []string{"log", "--graph", "--show-value=false", spec.CreateValueSpecString("ldb", s.LdbDir, "b1")})
s.Equal(diffRes1, res)
}
开发者ID:Richardphp,项目名称:noms,代码行数:52,代码来源:noms_log_test.go
示例7: TestNomsDiffSummarize
func (s *nomsDiffTestSuite) TestNomsDiffSummarize() {
datasetName := "diffSummarizeTest"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
ds, err := spec.GetDataset(str)
s.NoError(err)
defer ds.Database().Close()
ds, err = addCommit(ds, "first commit")
s.NoError(err)
r1 := spec.CreateHashSpecString("ldb", s.LdbDir, ds.HeadRef().TargetHash())
ds, err = addCommit(ds, "second commit")
s.NoError(err)
r2 := spec.CreateHashSpecString("ldb", s.LdbDir, ds.HeadRef().TargetHash())
out, _ := s.Run(main, []string{"diff", "--summarize", r1, r2})
s.Contains(out, "Comparing commit values")
s.Contains(out, "1 insertion (100.00%), 1 deletion (100.00%), 0 changes (0.00%), (1 value vs 1 value)")
out, _ = s.Run(main, []string{"diff", "--summarize", r1 + ".value", r2 + ".value"})
s.NotContains(out, "Comparing commit values")
ds, err = ds.CommitValue(types.NewList(types.Number(1), types.Number(2), types.Number(3), types.Number(4)))
s.NoError(err)
r3 := spec.CreateHashSpecString("ldb", s.LdbDir, ds.HeadRef().TargetHash()) + ".value"
ds, err = ds.CommitValue(types.NewList(types.Number(1), types.Number(222), types.Number(4)))
s.NoError(err)
r4 := spec.CreateHashSpecString("ldb", s.LdbDir, ds.HeadRef().TargetHash()) + ".value"
out, _ = s.Run(main, []string{"diff", "--summarize", r3, r4})
s.Contains(out, "1 insertion (25.00%), 2 deletions (50.00%), 0 changes (0.00%), (4 values vs 3 values)")
}
开发者ID:Richardphp,项目名称:noms,代码行数:33,代码来源:noms_diff_test.go
示例8: TestSimpleFile
func (s *fuseTestSuite) TestSimpleFile() {
datasetName := "TestSimpleFile"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
var testfs pathfs.FileSystem
start(str, func(fs pathfs.FileSystem) { testfs = fs })
file, code := testfs.Create("coconut", uint32(os.O_CREATE|os.O_RDWR), 0644, nil)
assert.Equal(s.T(), fuse.OK, code)
n, code := file.Write([]byte("Lime!"), 0)
assert.Equal(s.T(), uint32(5), n)
assertAttr(s, testfs, "coconut", 0644|fuse.S_IFREG, 5)
data := make([]byte, 5)
rr, code := file.Read(data, 0)
assert.Equal(s.T(), fuse.OK, code)
assert.Equal(s.T(), 5, rr.Size())
assert.Equal(s.T(), "Lime!", string(data))
code = testfs.Truncate("coconut", 4, nil)
assert.Equal(s.T(), fuse.OK, code)
assertAttr(s, testfs, "coconut", 0644|fuse.S_IFREG, 4)
rr, code = file.Read(data, 0)
assert.Equal(s.T(), fuse.OK, code)
assert.Equal(s.T(), 4, rr.Size())
assert.Equal(s.T(), "Lime!", string(data))
}
开发者ID:Richardphp,项目名称:noms,代码行数:28,代码来源:rw_test.go
示例9: TestCSVImporterWithPipe
func (s *testSuite) TestCSVImporterWithPipe() {
input, err := ioutil.TempFile(s.TempDir, "")
d.Chk.NoError(err)
defer input.Close()
defer os.Remove(input.Name())
_, err = input.WriteString("a|b\n1|2\n")
d.Chk.NoError(err)
setName := "csv"
dataspec := spec.CreateValueSpecString("ldb", s.LdbDir, setName)
stdout, stderr := s.Run(main, []string{"--no-progress", "--column-types", "String,Number", "--delimiter", "|", input.Name(), dataspec})
s.Equal("", stdout)
s.Equal("", stderr)
cs := chunks.NewLevelDBStore(s.LdbDir, "", 1, false)
ds := dataset.NewDataset(datas.NewDatabase(cs), setName)
defer ds.Database().Close()
defer os.RemoveAll(s.LdbDir)
l := ds.HeadValue().(types.List)
s.Equal(uint64(1), l.Len())
v := l.Get(0)
st := v.(types.Struct)
s.Equal(types.String("1"), st.Get("a"))
s.Equal(types.Number(2), st.Get("b"))
}
开发者ID:Richardphp,项目名称:noms,代码行数:27,代码来源:importer_test.go
示例10: TestImportFromFile
func (s *testSuite) TestImportFromFile() {
assert := s.Assert()
f, err := ioutil.TempFile("", "TestImportFromFile")
assert.NoError(err)
f.Write([]byte("abcdef"))
f.Close()
dsName := spec.CreateValueSpecString("ldb", s.LdbDir, "ds")
s.Run(main, []string{f.Name(), dsName})
db, blob, err := spec.GetPath(dsName + ".value")
assert.NoError(err)
expected := types.NewBlob(bytes.NewBufferString("abcdef"))
assert.True(expected.Equals(blob))
meta := db.Head("ds").Get(datas.MetaField).(types.Struct)
metaDesc := meta.Type().Desc.(types.StructDesc)
assert.Equal(2, metaDesc.Len())
assert.NotNil(metaDesc.Field("date"))
assert.Equal(f.Name(), string(meta.Get("file").(types.String)))
db.Close()
}
开发者ID:Richardphp,项目名称:noms,代码行数:26,代码来源:fetch_test.go
示例11: TestCSVImportSkipRecordsCustomHeader
func (s *testSuite) TestCSVImportSkipRecordsCustomHeader() {
input, err := ioutil.TempFile(s.TempDir, "")
d.Chk.NoError(err)
defer input.Close()
defer os.Remove(input.Name())
_, err = input.WriteString("a,b\n")
d.Chk.NoError(err)
_, err = input.WriteString("7,8\n")
d.Chk.NoError(err)
setName := "csv"
dataspec := spec.CreateValueSpecString("ldb", s.LdbDir, setName)
stdout, stderr := s.Run(main, []string{"--no-progress", "--skip-records", "1", "--header", "x,y", input.Name(), dataspec})
s.Equal("", stdout)
s.Equal("", stderr)
cs := chunks.NewLevelDBStore(s.LdbDir, "", 1, false)
ds := dataset.NewDataset(datas.NewDatabase(cs), setName)
defer ds.Database().Close()
defer os.RemoveAll(s.LdbDir)
l := ds.HeadValue().(types.List)
s.Equal(uint64(1), l.Len())
v := l.Get(0)
st := v.(types.Struct)
s.Equal(types.String("7"), st.Get("x"))
s.Equal(types.String("8"), st.Get("y"))
}
开发者ID:Richardphp,项目名称:noms,代码行数:30,代码来源:importer_test.go
示例12: TestImportFromStdin
func (s *testSuite) TestImportFromStdin() {
assert := s.Assert()
oldStdin := os.Stdin
newStdin, blobOut, err := os.Pipe()
assert.NoError(err)
os.Stdin = newStdin
defer func() {
os.Stdin = oldStdin
}()
go func() {
blobOut.Write([]byte("abcdef"))
blobOut.Close()
}()
dsName := spec.CreateValueSpecString("ldb", s.LdbDir, "ds")
// Run() will return when blobOut is closed.
s.Run(main, []string{"--stdin", dsName})
db, blob, err := spec.GetPath(dsName + ".value")
assert.NoError(err)
expected := types.NewBlob(bytes.NewBufferString("abcdef"))
assert.True(expected.Equals(blob))
meta := db.Head("ds").Get(datas.MetaField).(types.Struct)
// The meta should only have a "date" field.
metaDesc := meta.Type().Desc.(types.StructDesc)
assert.Equal(1, metaDesc.Len())
assert.NotNil(metaDesc.Field("date"))
db.Close()
}
开发者ID:Richardphp,项目名称:noms,代码行数:35,代码来源:fetch_test.go
示例13: TestNomsDs
func (s *nomsDsTestSuite) TestNomsDs() {
dir := s.LdbDir
cs := chunks.NewLevelDBStore(dir+"/name", "", 24, false)
ds := datas.NewDatabase(cs)
id := "testdataset"
set := dataset.NewDataset(ds, id)
set, err := set.CommitValue(types.String("Commit Value"))
s.NoError(err)
id2 := "testdataset2"
set2 := dataset.NewDataset(ds, id2)
set2, err = set2.CommitValue(types.String("Commit Value2"))
s.NoError(err)
err = ds.Close()
s.NoError(err)
dbSpec := spec.CreateDatabaseSpecString("ldb", dir+"/name")
datasetName := spec.CreateValueSpecString("ldb", dir+"/name", id)
dataset2Name := spec.CreateValueSpecString("ldb", dir+"/name", id2)
// both datasets show up
rtnVal, _ := s.Run(main, []string{"ds", dbSpec})
s.Equal(id+"\n"+id2+"\n", rtnVal)
// both datasets again, to make sure printing doesn't change them
rtnVal, _ = s.Run(main, []string{"ds", dbSpec})
s.Equal(id+"\n"+id2+"\n", rtnVal)
// delete one dataset, print message at delete
rtnVal, _ = s.Run(main, []string{"ds", "-d", datasetName})
s.Equal("Deleted "+datasetName+" (was #6ebc05f71q4sk2psi534fom9se228161)\n", rtnVal)
// print datasets, just one left
rtnVal, _ = s.Run(main, []string{"ds", dbSpec})
s.Equal(id2+"\n", rtnVal)
// delete the second dataset
rtnVal, _ = s.Run(main, []string{"ds", "-d", dataset2Name})
s.Equal("Deleted "+dataset2Name+" (was #f5qtovr9mv7mjj2uoq7flcfpksgf0s2j)\n", rtnVal)
// print datasets, none left
rtnVal, _ = s.Run(main, []string{"ds", dbSpec})
s.Equal("", rtnVal)
}
开发者ID:Richardphp,项目名称:noms,代码行数:47,代码来源:noms_ds_test.go
示例14: TestSyncValidation
func (s *nomsSyncTestSuite) TestSyncValidation() {
source1 := dataset.NewDataset(datas.NewDatabase(chunks.NewLevelDBStore(s.LdbDir, "", 1, false)), "src")
source1, err := source1.CommitValue(types.Number(42))
s.NoError(err)
source1HeadRef := source1.Head().Hash()
source1.Database().Close()
sourceSpecMissingHashSymbol := spec.CreateValueSpecString("ldb", s.LdbDir, source1HeadRef.String())
ldb2dir := path.Join(s.TempDir, "ldb2")
sinkDatasetSpec := spec.CreateValueSpecString("ldb", ldb2dir, "dest")
defer func() {
err := recover()
s.Equal(exitError{-1}, err)
}()
s.Run(main, []string{"sync", sourceSpecMissingHashSymbol, sinkDatasetSpec})
}
开发者ID:Richardphp,项目名称:noms,代码行数:18,代码来源:noms_sync_test.go
示例15: TestNomsDiffOutputNotTruncated
func (s *nomsDiffTestSuite) TestNomsDiffOutputNotTruncated() {
datasetName := "diffTest"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
ds, err := spec.GetDataset(str)
s.NoError(err)
ds, err = addCommit(ds, "first commit")
s.NoError(err)
r1 := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+ds.HeadRef().TargetHash().String())
ds, err = addCommit(ds, "second commit")
s.NoError(err)
r2 := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+ds.HeadRef().TargetHash().String())
ds.Database().Close()
out, _ := s.Run(main, []string{"diff", r1, r2})
s.True(strings.HasSuffix(out, "\"second commit\"\n }\n"), out)
}
开发者ID:Richardphp,项目名称:noms,代码行数:18,代码来源:noms_diff_test.go
示例16: TestNomsLog
func (s *nomsLogTestSuite) TestNomsLog() {
datasetName := "dsTest"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
ds, err := spec.GetDataset(str)
s.NoError(err)
ds.Database().Close()
s.Panics(func() { s.Run(main, []string{"log", str}) })
testCommitInResults(s, str, 1)
testCommitInResults(s, str, 2)
}
开发者ID:Richardphp,项目名称:noms,代码行数:12,代码来源:noms_log_test.go
示例17: TestFile
func (s *fuseTestSuite) TestFile() {
datasetName := "TestFile"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
var testfs pathfs.FileSystem
start(str, func(fs pathfs.FileSystem) { testfs = fs })
_, code := testfs.Create("pokemon.go", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
assert.Equal(s.T(), fuse.OK, code)
assertAttr(s, testfs, "pokemon.go", 0644|fuse.S_IFREG, 0)
}
开发者ID:Richardphp,项目名称:noms,代码行数:12,代码来源:basics_test.go
示例18: TestDir
func (s *fuseTestSuite) TestDir() {
datasetName := "TestDir"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
var testfs pathfs.FileSystem
start(str, func(fs pathfs.FileSystem) { testfs = fs })
code := testfs.Mkdir("noms", 0777, nil)
assert.Equal(s.T(), fuse.OK, code)
assertAttr(s, testfs, "noms", 0777|fuse.S_IFDIR, 0)
}
开发者ID:Richardphp,项目名称:noms,代码行数:12,代码来源:basics_test.go
示例19: TestNomsGraph3
func (s *nomsLogTestSuite) TestNomsGraph3() {
str := spec.CreateDatabaseSpecString("ldb", s.LdbDir)
db, err := spec.GetDatabase(str)
s.NoError(err)
w := dataset.NewDataset(db, "w")
w, err = addCommit(w, "1")
s.NoError(err)
w, err = addCommit(w, "2")
s.NoError(err)
x := dataset.NewDataset(db, "x")
x, err = addBranchedDataset(x, w, "20-x")
s.NoError(err)
y := dataset.NewDataset(db, "y")
y, err = addBranchedDataset(y, w, "200-y")
s.NoError(err)
z := dataset.NewDataset(db, "z")
z, err = addBranchedDataset(z, w, "2000-z")
s.NoError(err)
w, err = mergeDatasets(w, x, "22-wx")
s.NoError(err)
w, err = mergeDatasets(w, y, "222-wy")
s.NoError(err)
_, err = mergeDatasets(w, z, "2222-wz")
s.NoError(err)
db.Close()
res, _ := s.Run(main, []string{"log", "--graph", "--show-value=true", spec.CreateValueSpecString("ldb", s.LdbDir, "w")})
test.EqualsIgnoreHashes(s.T(), graphRes3, res)
res, _ = s.Run(main, []string{"log", "--graph", "--show-value=false", spec.CreateValueSpecString("ldb", s.LdbDir, "w")})
test.EqualsIgnoreHashes(s.T(), diffRes3, res)
}
开发者ID:Richardphp,项目名称:noms,代码行数:40,代码来源:noms_log_test.go
示例20: TestCSVExporter
// FIXME: run with pipe
func (s *testSuite) TestCSVExporter() {
setName := "csv"
header := []string{"a", "b", "c"}
payload := [][]string{
[]string{"5", "7", "100"},
[]string{"4", "10", "255"},
[]string{"512", "12", "55"},
}
structName := "SomeStruct"
// Setup data store
cs := chunks.NewLevelDBStore(s.LdbDir, "", 1, false)
ds := dataset.NewDataset(datas.NewDatabase(cs), setName)
typ := types.MakeStructType(structName, header, []*types.Type{
types.StringType, types.StringType, types.StringType,
})
// Build data rows
structs := make([]types.Value, len(payload))
for i, row := range payload {
fields := make(types.ValueSlice, len(header))
for j, v := range row {
fields[j] = types.String(v)
}
structs[i] = types.NewStructWithType(typ, fields)
}
ds.CommitValue(types.NewList(structs...))
ds.Database().Close()
// Run exporter
dataspec := spec.CreateValueSpecString("ldb", s.LdbDir, setName)
stdout, stderr := s.Run(main, []string{dataspec})
s.Equal("", stderr)
// Verify output
csvReader := csv.NewReader(strings.NewReader(stdout))
row, err := csvReader.Read()
d.Chk.NoError(err)
s.Equal(header, row)
for i := 0; i < len(payload); i++ {
row, err := csvReader.Read()
d.Chk.NoError(err)
s.Equal(payload[i], row)
}
_, err = csvReader.Read()
s.Equal(io.EOF, err)
}
开发者ID:Richardphp,项目名称:noms,代码行数:53,代码来源:exporter_test.go
注:本文中的github.com/attic-labs/noms/go/spec.CreateValueSpecString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论