From 87ec0bf964665d15273cd2ca39ffaa65840f5a0d Mon Sep 17 00:00:00 2001 From: Dustin Long Date: Mon, 25 Feb 2019 14:44:46 -0500 Subject: [PATCH 1/2] fix(dataset): Dataset has transient field NumVersions --- dataset.go | 3 +++ 1 file changed, 3 insertions(+) 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 ( From cbac108d9daeb346e0b83f7de0c00b8077f06d2b Mon Sep 17 00:00:00 2001 From: Dustin Long Date: Mon, 25 Feb 2019 16:12:58 -0500 Subject: [PATCH 2/2] fix(dataset): Test for DropTransientValues --- dataset_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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) {