github.com/ndau/noms@v1.0.5/cmd/noms/noms_root_test.go (about)

     1  // Copyright 2016 Attic Labs, Inc. All rights reserved.
     2  // Licensed under the Apache License, version 2.0:
     3  // http://www.apache.org/licenses/LICENSE-2.0
     4  
     5  package main
     6  
     7  import (
     8  	"testing"
     9  
    10  	"github.com/ndau/noms/go/spec"
    11  	"github.com/ndau/noms/go/types"
    12  	"github.com/ndau/noms/go/util/clienttest"
    13  	"github.com/stretchr/testify/suite"
    14  )
    15  
    16  func TestNomsRoot(t *testing.T) {
    17  	suite.Run(t, &nomsRootTestSuite{})
    18  }
    19  
    20  type nomsRootTestSuite struct {
    21  	clienttest.ClientTestSuite
    22  }
    23  
    24  func (s *nomsRootTestSuite) TestBasic() {
    25  	datasetName := "root-get"
    26  	dsSpec := spec.CreateValueSpecString("nbs", s.DBDir, datasetName)
    27  	sp, err := spec.ForDataset(dsSpec)
    28  	s.NoError(err)
    29  	defer sp.Close()
    30  
    31  	ds := sp.GetDataset()
    32  	dbSpecStr := spec.CreateDatabaseSpecString("nbs", s.DBDir)
    33  	ds, _ = ds.Database().CommitValue(ds, types.String("hello!"))
    34  	c1, _ := s.MustRun(main, []string{"root", dbSpecStr})
    35  	s.Equal("5te45oue1g918rpcvmc3d2emqkse4fhq\n", c1)
    36  
    37  	ds, _ = ds.Database().CommitValue(ds, types.String("goodbye"))
    38  	c2, _ := s.MustRun(main, []string{"root", dbSpecStr})
    39  	s.Equal("nm81pr21t66nec3v8jts5e37njg5ab1g\n", c2)
    40  
    41  	// TODO: Would be good to test successful --update too, but requires changes to MustRun to allow
    42  	// input because of prompt :(.
    43  }