Skip to content

Commit

Permalink
chore(ds): update 'data' filenames to 'body'
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed May 16, 2019
1 parent 2de995a commit b30516e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ds/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ func (d *Dataset) GetBody(thread *starlark.Thread, _ *starlark.Builtin, args sta
if err != nil {
return starlark.None, err
}
provider.SetBodyFile(qfs.NewMemfileBytes("data.json", data))
provider.SetBodyFile(qfs.NewMemfileBytes("body.json", data))

rr, err := dsio.NewEntryReader(provider.Structure, qfs.NewMemfileBytes("data.json", data))
rr, err := dsio.NewEntryReader(provider.Structure, qfs.NewMemfileBytes("body.json", data))
if err != nil {
return starlark.None, fmt.Errorf("error allocating data reader: %s", err)
}
Expand Down Expand Up @@ -310,7 +310,7 @@ func (d *Dataset) SetBody(thread *starlark.Thread, _ *starlark.Builtin, args sta
return starlark.None, fmt.Errorf("expected data for '%s' format to be a string", df)
}

d.write.SetBodyFile(qfs.NewMemfileBytes(fmt.Sprintf("data.%s", df), []byte(string(str))))
d.write.SetBodyFile(qfs.NewMemfileBytes(fmt.Sprintf("body.%s", df), []byte(string(str))))
d.modBody = true
d.bodyCache = nil
return starlark.None, nil
Expand Down
2 changes: 1 addition & 1 deletion ds/dataset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bat,3,meh
},
},
}
ds.SetBodyFile(qfs.NewMemfileBytes("data.csv", []byte(text)))
ds.SetBodyFile(qfs.NewMemfileBytes("body.csv", []byte(text)))

d := NewDataset(ds, nil)
d.SetMutable(&dataset.Dataset{
Expand Down
4 changes: 2 additions & 2 deletions ds/testdata/test.star
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ assert.eq(ds.set_body("[[1,2,3]]", parse_as="json"), None)
assert.eq(ds.get_body(), bd)

# csv_ds is a global variable provided by dataset_test.go
# "cycling" csv data through starlark shouldn't have significant effects on the
# round-tripping csv data through starlark shouldn't have significant effects on the
# encoded data. whitespace is *not* significant.
# csv data is one of the harder formats, where there header row must be preserved
csv_ds.set_body(csv_ds.get_body())

expect_data = [["foo",1,"true"], ["bar",2,"false"], ["bat",3,"meh"]]
assert.eq(expect_data, csv_ds.get_body())
assert.eq(csv_ds.get_structure()['format'], 'csv')
assert.eq(csv_ds.get_structure()['format'], 'csv')

0 comments on commit b30516e

Please sign in to comment.