func TestDeleteItem(t *testing.T) { testhelper.PrepareConfig() item := NewItem(3, 3, "spent", "first spent", 1.2) item.Save() item.Delete() }
func TestSaveItem(t *testing.T) { testhelper.PrepareConfig() item := NewItem(3, 3, "spent", "first spent", 1.2) item.Save() if item.Id == 0 { t.Fail() } }
func TestSaveCategory(t *testing.T) { testhelper.PrepareConfig() category := NewCategory(1, "spent", "test", "test") category.Save() if category.Id == 0 { t.Fail() } }
func TestSaveUser(t *testing.T) { testhelper.PrepareConfig() user := NewUser("user", "email", "spent") user.Save() if user.Id == 0 { t.Fail() } }
func TestNewAddCategoryCommand(t *testing.T) { testhelper.PrepareConfig() categoryTitle := "Category Title" categoryType := "spent" addCategoryCommand = NewAddCategoryCommand(Attributes{ Title: &categoryTitle, Slug: &categoryTitle, ItemType: &categoryType, }) }
func TestFindItem(t *testing.T) { testhelper.PrepareConfig() item := NewItem(3, 3, "spent", "first spent", 1.2) item.Save() newitem := &Item{} newitem.Find(item.Id) // log.Fatal(item) if newitem.Amount != 1.2 { t.Fail() } }
func TestFindCategory(t *testing.T) { testhelper.PrepareConfig() category := NewCategory(1, "spent", "test", "test") category.Save() newcategory := &Category{} newcategory.Find(category.Id) // log.Fatal(item) if newcategory.Title != "test" { t.Fail() } }
func TestFindUser(t *testing.T) { testhelper.PrepareConfig() user := NewUser("user", "email", "spent") user.Save() newuser := &User{} newuser.Find(user.Id) // log.Fatal(item) if newuser.Email != "email" { t.Fail() } }
func TestNewAddItemCommand(t *testing.T) { testhelper.PrepareConfig() amount := 20.00 categoryTitle := "Category Title" itemType := "Item Type" comment := "Comment" addItemCommand = NewAddItemCommand(Attributes{ Amount: &amount, CategoryTitle: &categoryTitle, ItemType: &itemType, Comment: &comment, }) }
func TestGetCategoryTitle(t *testing.T) { testhelper.PrepareConfig() category := NewCategory(1, "spent", "test", "test") category.Save() item := NewItem(3, category.Id, "spent", "first spent", 1.2) item.Save() newitem := &Item{} newitem.Find(item.Id) if newitem.GetCategoryTitle() != "test" { t.Fail() } }
func TestAddItemCommandValidate(t *testing.T) { testhelper.PrepareConfig() addItemCommand.Validate() }
func TestNewCategory(t *testing.T) { testhelper.PrepareConfig() _ = NewCategory(1, "spent", "test", "test") }
func TestAddCategoryCommandRun(t *testing.T) { testhelper.PrepareConfig() addCategoryCommand.Run() }
func TestAddItemCommandRun(t *testing.T) { testhelper.PrepareConfig() addItemCommand.Run() }
func TestNewItem(t *testing.T) { testhelper.PrepareConfig() _ = NewItem(3, 3, "", "first spent", 1.2) }
func TestAddItemCommandUsage(t *testing.T) { testhelper.PrepareConfig() addItemCommand.Usage(nil) }
func TestNewUser(t *testing.T) { testhelper.PrepareConfig() _ = NewUser("user", "email", "spent") }