// NOTE: if the test input data is changed, this must be updated! func TestCommentValidity(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestCommentValidity <<<<<<<<<<<<<<<<<<<<<<<<<<") // Check lastID if lID := data.LastCommentID(); lID != 3 { t.Errorf("LastId: %v is incorrect.", lID) } // Make sure we've got the data we think we should have - check random data: r, e := data.FindReportComments(101) fmt.Println(r) if e != nil { t.Errorf("FindId failed: %q.", e) } if l := len(r); l != 2 { t.Errorf("Size of comments for report 101 is %d should be %d.", l, 2) } sExp := "The second test comment for report 101" if cmt := r[1].Comment; cmt != sExp { t.Errorf("The text of the second comment for report 101 is %q should be %q.", cmt, sExp) } var cdval data.CustomTime cdval.UnmarshalText([]byte("2015-05-21T11:30:30")) if r[1].DateCreated != cdval { t.Errorf("Invalid DateCreated: %s should be: %s", r[1].DateCreated, cdval) } }
// NOTE: if the test input data is changed, this must be updated! func TestReportValidity(t *testing.T) { fmt.Println("\n\n>>>>>>>>>>>>>>>>>>> TestReportValidity <<<<<<<<<<<<<<<<<<<<<<<<<<") // Check lastID if lID := data.LastID(); lID != 102 { t.Errorf("LastId: %v is incorrect.", lID) } // Make sure we've got the data we think we should have - check random data: r, e := data.GetID(101) if e != nil { t.Errorf("FindId failed: %q.", e) } fmt.Printf("Id 100 - type: %T.\n", r) var cdval data.CustomTime cdval.UnmarshalText([]byte("2015-10-20T13:45:30")) if r.DateCreated != cdval { t.Errorf("Invalid DateCreated: %s should be: %s", r.DateCreated, cdval) } sval := "2222" if r.DeviceID != sval { t.Errorf("Invalid DeviceId: %s should be: %s", r.DeviceID, sval) } fval := -121.886329 if r.LongitudeV != fval { t.Errorf("Invalid Longitude: %v should be: %v", r.LongitudeV, fval) } bval := true if r.AuthIsAnon() != bval { t.Errorf("Invalid AuthorIsAnonymous: %v should be: %v", r.AuthIsAnon(), bval) } }