github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/model/analytics_row_test.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "strings" 8 "testing" 9 ) 10 11 func TestAnalyticsRowJson(t *testing.T) { 12 a1 := AnalyticsRow{} 13 a1.Name = "2015-10-12" 14 a1.Value = 12345.0 15 json := a1.ToJson() 16 ra1 := AnalyticsRowFromJson(strings.NewReader(json)) 17 18 if a1.Name != ra1.Name { 19 t.Fatal("days didn't match") 20 } 21 } 22 23 func TestAnalyticsRowsJson(t *testing.T) { 24 a1 := AnalyticsRow{} 25 a1.Name = "2015-10-12" 26 a1.Value = 12345.0 27 28 var a1s AnalyticsRows = make([]*AnalyticsRow, 1) 29 a1s[0] = &a1 30 31 ljson := a1s.ToJson() 32 results := AnalyticsRowsFromJson(strings.NewReader(ljson)) 33 34 if a1s[0].Name != results[0].Name { 35 t.Fatal("Ids do not match") 36 } 37 }