Skip to content

Commit

Permalink
fix(dataset): Dataset has transient field NumVersions
Browse files Browse the repository at this point in the history
Merge pull request #177 from qri-io/num-versions
  • Loading branch information
dustmop authored Feb 25, 2019
2 parents 926d579 + cbac108 commit bdf0bb8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Dataset struct {
PreviousPath string `json:"previousPath,omitempty"`
// ProfileID of dataset owner, transient
ProfileID string `json:"profileID,omitempty"`
// Number of versions this dataset has, transient
NumVersions int `json:"numVersions,omitempty"`
// Qri is a key for both identifying this document type, and versioning the
// dataset document definition itself.
Qri string `json:"qri"`
Expand Down Expand Up @@ -132,6 +134,7 @@ func (ds *Dataset) DropTransientValues() {
ds.Name = ""
ds.Path = ""
ds.ProfileID = ""
ds.NumVersions = 0
}

var (
Expand Down
27 changes: 26 additions & 1 deletion dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,32 @@ import (
)

func TestDatasetDropTransientValues(t *testing.T) {
t.Log("TODO (b5)")
ds := Dataset{
Body: []int{1,2,3},
Name: "three numbers",
Path: "/tmp/ds",
ProfileID: "QmBlahBlah",
NumVersions: 4,
}
ds.DropTransientValues()
if !ds.IsEmpty() {
t.Errorf("error, dropping transient values should leave an empty dataset")
}

ds = Dataset{
Body: []int{1,2,3},
Name: "three numbers",
Path: "/tmp/ds",
ProfileID: "QmBlahBlah",
NumVersions: 4,
Meta: &Meta{
Title: "a title",
},
}
ds.DropTransientValues()
if ds.IsEmpty() {
t.Errorf("error dataset should not be empty")
}
}

func TestDatasetOpenBodyFile(t *testing.T) {
Expand Down

0 comments on commit bdf0bb8

Please sign in to comment.