func TestReadItemComment(t *testing.T) { readComment := new(data.ItemComment) testRead(t, "/items/"+strconv.FormatInt(item.ID, 10)+"/comments/"+strconv.FormatInt(comment.ID, 10), readComment) readComment.UpdateTime = comment.UpdateTime structJSONCompare(t, comment, readComment) }
func scanItemComment(comment *data.ItemComment, rows *sql.Rows) error { var updateTimeString string err := rows.Scan( &comment.ID, &comment.ItemID, &comment.Author, &comment.Body, &updateTimeString, ) if err != nil { return err } updateTime, err := time.Parse("2006-01-02 15:04:05", updateTimeString) // this assumes UTC as timezone if err != nil { log.Println("ItemComment scanner failed to parse time. " + updateTimeString) return err } comment.UpdateTime = updateTime return nil }
func TestSelectItemComment(t *testing.T) { selectedComment := new(data.ItemComment) selectedComment.ID = comment.ID err := Select(selectedComment) if err != nil { t.Error(err) } t.Log(comment.UpdateTime.UTC()) t.Log(selectedComment.UpdateTime.UTC()) selectedComment.UpdateTime = comment.UpdateTime structJSONCompare(t, comment, selectedComment) }