diff --git a/dataset.go b/dataset.go index 80eb483..205793c 100644 --- a/dataset.go +++ b/dataset.go @@ -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"` @@ -132,6 +134,7 @@ func (ds *Dataset) DropTransientValues() { ds.Name = "" ds.Path = "" ds.ProfileID = "" + ds.NumVersions = 0 } var ( diff --git a/dataset_test.go b/dataset_test.go index 1a7d069..e2789a8 100644 --- a/dataset_test.go +++ b/dataset_test.go @@ -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) {