Rename author to authors and subject to tags

This commit is contained in:
Las Zenow 2016-07-30 07:36:58 -04:00
parent e72de38725
commit 7f9c172853
17 changed files with 37 additions and 39 deletions

View file

@ -5,15 +5,14 @@ import (
"time"
)
// TODO: Author -> Authors, Subject -> Tags
type Book struct {
Id string
Title string
Author []string `sql:"authors" pg:",array"`
Authors []string `sql:"authors" pg:",array"`
Contributor string
Publisher string
Description string
Subject []string `sql:"tags" pg:",array"`
Tags []string `sql:"tags" pg:",array"`
Date string
Lang string
Isbn string

View file

@ -3,9 +3,9 @@ package database
import "testing"
var book = Book{
Id: "r_m-IOzzIbA6QK5w",
Title: "some title",
Author: []string{"Alice", "Bob"},
Id: "r_m-IOzzIbA6QK5w",
Title: "some title",
Authors: []string{"Alice", "Bob"},
}
func TestAddAndDeleteBook(t *testing.T) {
@ -61,8 +61,8 @@ func TestActiveBook(t *testing.T) {
if !b.Active {
t.Error("Book is not activated")
}
if b.Author[0] != books[0].Author[0] {
t.Error("Book author don't match : '", b.Author, "' <=> '", book.Author, "'")
if b.Authors[0] != books[0].Authors[0] {
t.Error("Book author don't match : '", b.Authors, "' <=> '", book.Authors, "'")
}
bs, num, err := db.GetBooks(book.Title, 20, 0)
@ -72,8 +72,8 @@ func TestActiveBook(t *testing.T) {
if num != 1 || len(bs) != 1 {
t.Fatal("We got a un expected number of books: ", num, bs)
}
if bs[0].Author[0] != book.Author[0] {
t.Error("Book author don't match : '", bs[0].Author, "' <=> '", book.Author, "'")
if bs[0].Authors[0] != book.Authors[0] {
t.Error("Book author don't match : '", bs[0].Authors, "' <=> '", book.Authors, "'")
}
bs, num, err = db.GetBooks("none", 20, 0)

View file

@ -21,7 +21,6 @@ type Visits struct {
Count int "count"
}
// TODO: split code in files
func (db *pgDB) AddStats(stats interface{}) error {
return nil
}