Files
dolt/samples/js/fs/integration_test.go
cmasone-attic 2e462b11a5 Make Database a mutable API that vends immutable Datasets (#2617)
Noms SDK users frequently shoot themselves in the foot because they're
holding onto an "old" Database object. That is, they have a Database
tucked away in some internal state, they call Commit() on it, and
don't replace the object in their internal state with the new Database
returned from Commit.

This PR changes the Database and Dataset Go API to be in line with the
proposal in Issue #2589. JS follows in a separate patch.
2016-09-26 12:18:14 -07:00

51 lines
1.1 KiB
Go

// Copyright 2016 Attic Labs, Inc. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package fs
import (
"io/ioutil"
"testing"
"github.com/attic-labs/noms/go/types"
"github.com/attic-labs/noms/go/util/integrationtest"
)
const dsName = "test-fs"
func TestIntegration(t *testing.T) {
integrationtest.Run(t, &testSuite{})
}
type testSuite struct {
integrationtest.IntegrationSuite
}
func (s *testSuite) NodeArgs() []string {
return []string{"./test-data.txt", s.ValueSpecString(dsName)}
}
func (s *testSuite) Teardown() {
out := s.NodeOutput()
s.Contains(out, "1 of 1 entries")
s.Contains(out, "done")
db := s.Database()
defer db.Close()
ds := db.GetDataset(dsName)
v := ds.HeadValue()
s.True(v.Type().Equals(types.MakeStructType("File",
[]string{"content"},
[]*types.Type{
types.MakeRefType(types.BlobType),
},
)))
s.Equal("File", v.(types.Struct).Type().Desc.(types.StructDesc).Name)
b := v.(types.Struct).Get("content").(types.Ref).TargetValue(db).(types.Blob)
bs, err := ioutil.ReadAll(b.Reader())
s.NoError(err)
s.Equal([]byte("Hello World!\n"), bs)
}