Merge pull request #2093 from derailed/BUG_PointPrecision

Point Precision not getting marshaled correctly...
pull/2104/head
Cory LaNou 2015-03-27 21:10:04 -06:00
commit a4b133c601
2 changed files with 14 additions and 12 deletions

View File

@ -295,10 +295,12 @@ func (p *Point) MarshalJSON() ([]byte, error) {
Tags map[string]string `json:"tags,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
Precision string `json:"precision,omitempty"`
}{
Name: p.Name,
Tags: p.Tags,
Fields: p.Fields,
Name: p.Name,
Tags: p.Tags,
Fields: p.Fields,
Precision: p.Precision,
}
// Let it omit empty if it's really zero
if !p.Timestamp.IsZero() {

View File

@ -332,7 +332,7 @@ func TestPoint_MarshalOmitempty(t *testing.T) {
name: "with precision",
point: client.Point{Name: "cpu", Fields: map[string]interface{}{"value": 1.1}, Precision: "ms"},
now: now,
expected: `{"name":"cpu","fields":{"value":1.1}}`,
expected: `{"name":"cpu","fields":{"value":1.1},"precision":"ms"}`,
},
}
@ -390,14 +390,14 @@ func emptyTestServer() *httptest.Server {
func TestBatchPoints_Normal(t *testing.T) {
var bp client.BatchPoints
data := []byte(`
{
"database": "foo",
"retentionPolicy": "bar",
"points": [
{
"name": "cpu",
"tags": {
"host": "server01"
{
"database": "foo",
"retentionPolicy": "bar",
"points": [
{
"name": "cpu",
"tags": {
"host": "server01"
},
"timestamp": 14244733039069373,
"precision": "n",