Skip to content

Commit

Permalink
load initial data
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Oct 22, 2023
1 parent 274f7dc commit 07dd1a9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,33 @@ func TestDataMerge(t *testing.T) {
assert.Assert(t, newData.Tables["tags"] != data.Tables["tags"], "tables should have been cloned")
assert.Assert(t, newData.Tables["tags"] != data2.Tables["tags"], "tables should have been cloned")
}

func TestDataClone(t *testing.T) {
data := &Data{
Tables: map[string]*Table{
"tags": {
ID: "tags",
Rows: Rows{
Row{Fields: map[string]any{"x": 1}},
Row{Fields: map[string]any{"x": 2}},
},
},
"posts": {
ID: "posts",
Rows: Rows{
Row{Fields: map[string]any{"a": 5}},
Row{Fields: map[string]any{"a": 3}},
Row{Fields: map[string]any{"a": 2}},
},
},
},
}

newData, err := data.Clone()
assert.NilError(t, err)

assert.Assert(t, is.Len(newData.Tables["tags"].Rows, 2))
assert.Assert(t, is.Len(newData.Tables["posts"].Rows, 3))
assert.Assert(t, newData.Tables["tags"] != data.Tables["tags"], "tables should have been cloned")
assert.Assert(t, newData.Tables["posts"] != data.Tables["posts"], "tables should have been cloned")
}

0 comments on commit 07dd1a9

Please sign in to comment.