refactor: change content field to description

Change the content field to description for the card type in preparation
for supporting card notes.
This commit is contained in:
Dan Anglin 2024-01-10 12:12:54 +00:00
parent c5a02bc703
commit f956b7da59
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
6 changed files with 30 additions and 30 deletions

View file

@ -200,8 +200,8 @@ func (b *Board) MoveToStatus(args MoveToStatusArgs) error {
}
type CardArgs struct {
NewTitle string
NewContent string
NewTitle string
NewDescription string
}
// CreateCard creates a card in the database.
@ -218,10 +218,10 @@ func (b *Board) CreateCard(args CardArgs) (int, error) {
}
card := Card{
ID: -1,
Title: args.NewTitle,
Content: args.NewContent,
Created: timestamp,
ID: -1,
Title: args.NewTitle,
Description: args.NewDescription,
Created: timestamp,
}
cardID, err := db.Write(b.db, db.CardBucket, &card)
@ -309,8 +309,8 @@ func (b *Board) UpdateCard(args UpdateCardArgs) error {
card.Title = args.NewTitle
}
if len(args.NewContent) > 0 {
card.Content = args.NewContent
if len(args.NewDescription) > 0 {
card.Description = args.NewDescription
}
if _, err := db.Write(b.db, db.CardBucket, &card); err != nil {

View file

@ -14,7 +14,7 @@ func (e CardNotExistError) Error() string {
type Card struct {
ID int
Title string
Content string
Description string
Created string
}

View file

@ -35,7 +35,7 @@ func TestCardLifecycle(t *testing.T) {
initialCardContent := "Ensure that this card is safely stored in the database."
expectedCardID := 1
expectedStatusID := 1
timestamp := time.Now().Format(time.DateOnly)
timestamp := time.Now().Format(time.DateTime)
t.Run("Test Create Card", testCreateCard(kanban, initialCardTitle, initialCardContent, expectedCardID, expectedStatusID))
@ -59,7 +59,7 @@ func testCreateCard(kanban board.Board, title, content string, expectedCardID, e
args := board.CardArgs{
NewTitle: title,
NewContent: content,
NewDescription: content,
}
if _, err := kanban.CreateCard(args); err != nil {
@ -87,7 +87,7 @@ func testCreateCard(kanban board.Board, title, content string, expectedCardID, e
}
}
func testReadCard(kanban board.Board, cardID int, wantTitle, wantContent, wantTimestamp string) func(t *testing.T) {
func testReadCard(kanban board.Board, cardID int, wantTitle, wantDescription, wantTimestamp string) func(t *testing.T) {
return func(t *testing.T) {
t.Log("When a card is read from the database.")
@ -102,10 +102,10 @@ func testReadCard(kanban board.Board, cardID int, wantTitle, wantContent, wantTi
t.Logf("%s\tExpected card title received, got: %s.", success, card.Title)
}
if card.Content != wantContent {
t.Errorf("%s\tUnexpected card content received, want: %s, got: %s.", failure, wantContent, card.Content)
if card.Description != wantDescription {
t.Errorf("%s\tUnexpected card content received, want: %s, got: %s.", failure, wantDescription, card.Description)
} else {
t.Logf("%s\tExpected card content received, got: %s.", success, card.Content)
t.Logf("%s\tExpected card content received, got: %s.", success, card.Description)
}
if card.Created != wantTimestamp {
@ -124,7 +124,7 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
CardID: cardID,
CardArgs: board.CardArgs{
NewTitle: newTitle,
NewContent: newContent,
NewDescription: newContent,
},
}
@ -140,7 +140,7 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
want := board.Card{
ID: cardID,
Title: newTitle,
Content: newContent,
Description: newContent,
Created: timestamp,
}
@ -160,7 +160,7 @@ func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newCon
CardID: cardID,
CardArgs: board.CardArgs{
NewTitle: "",
NewContent: newContent,
NewDescription: newContent,
},
}
@ -176,7 +176,7 @@ func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newCon
want := board.Card{
ID: cardID,
Title: expectedTitle,
Content: newContent,
Description: newContent,
Created: timestamp,
}

View file

@ -128,7 +128,7 @@ func testMoveCardToStatus(kanban board.Board) func(t *testing.T) {
title := "Test card."
cardArgs := board.CardArgs{NewTitle: title, NewContent: ""}
cardArgs := board.CardArgs{NewTitle: title, NewDescription: ""}
cardID, err := kanban.CreateCard(cardArgs)
if err != nil {

View file

@ -165,7 +165,7 @@ func TestReadAndWriteCards(t *testing.T) {
singleCard := board.Card{
ID: -1,
Title: "A test task.",
Content: "This task should be completed.",
Description: "This task should be completed.",
}
singleCardID := testWriteOneCard(t, database, singleCard)
@ -175,17 +175,17 @@ func TestReadAndWriteCards(t *testing.T) {
{
ID: -1,
Title: "Test card A.",
Content: "This is test card A.",
Description: "This is test card A.",
},
{
ID: -1,
Title: "Test card B.",
Content: "This is test card B.",
Description: "This is test card B.",
},
{
ID: -1,
Title: "Test card C.",
Content: "This is test card C.",
Description: "This is test card C.",
},
}
@ -225,7 +225,7 @@ func testReadOneCard(t *testing.T, database *bolt.DB, cardID int) {
want := board.Card{
ID: 1,
Title: "A test task.",
Content: "This task should be completed.",
Description: "This task should be completed.",
}
if !reflect.DeepEqual(got, want) {
@ -280,17 +280,17 @@ func testReadManyCards(t *testing.T, database *bolt.DB, cardIDs []int) {
{
ID: 2,
Title: "Test card A.",
Content: "This is test card A.",
Description: "This is test card A.",
},
{
ID: 3,
Title: "Test card B.",
Content: "This is test card B.",
Description: "This is test card B.",
},
{
ID: 4,
Title: "Test card C.",
Content: "This is test card C.",
Description: "This is test card C.",
},
}
@ -328,7 +328,7 @@ func TestDeleteOneCard(t *testing.T) {
card := board.Card{
ID: -1,
Title: "Test card",
Content: "",
Description: "",
}
cardID, err := db.Write(database, db.CardBucket, &card)

View file

@ -220,7 +220,7 @@ func (u *UI) initQuitModal() {
func (u *UI) newCard(title, content string) error {
args := board.CardArgs{
NewTitle: title,
NewContent: content,
NewDescription: content,
}
if _, err := u.board.CreateCard(args); err != nil {