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:
parent
c5a02bc703
commit
f956b7da59
6 changed files with 30 additions and 30 deletions
|
@ -200,8 +200,8 @@ func (b *Board) MoveToStatus(args MoveToStatusArgs) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CardArgs struct {
|
type CardArgs struct {
|
||||||
NewTitle string
|
NewTitle string
|
||||||
NewContent string
|
NewDescription string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateCard creates a card in the database.
|
// CreateCard creates a card in the database.
|
||||||
|
@ -218,10 +218,10 @@ func (b *Board) CreateCard(args CardArgs) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
card := Card{
|
card := Card{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: args.NewTitle,
|
Title: args.NewTitle,
|
||||||
Content: args.NewContent,
|
Description: args.NewDescription,
|
||||||
Created: timestamp,
|
Created: timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
cardID, err := db.Write(b.db, db.CardBucket, &card)
|
cardID, err := db.Write(b.db, db.CardBucket, &card)
|
||||||
|
@ -309,8 +309,8 @@ func (b *Board) UpdateCard(args UpdateCardArgs) error {
|
||||||
card.Title = args.NewTitle
|
card.Title = args.NewTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(args.NewContent) > 0 {
|
if len(args.NewDescription) > 0 {
|
||||||
card.Content = args.NewContent
|
card.Description = args.NewDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := db.Write(b.db, db.CardBucket, &card); err != nil {
|
if _, err := db.Write(b.db, db.CardBucket, &card); err != nil {
|
||||||
|
|
|
@ -14,7 +14,7 @@ func (e CardNotExistError) Error() string {
|
||||||
type Card struct {
|
type Card struct {
|
||||||
ID int
|
ID int
|
||||||
Title string
|
Title string
|
||||||
Content string
|
Description string
|
||||||
Created string
|
Created string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestCardLifecycle(t *testing.T) {
|
||||||
initialCardContent := "Ensure that this card is safely stored in the database."
|
initialCardContent := "Ensure that this card is safely stored in the database."
|
||||||
expectedCardID := 1
|
expectedCardID := 1
|
||||||
expectedStatusID := 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))
|
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{
|
args := board.CardArgs{
|
||||||
NewTitle: title,
|
NewTitle: title,
|
||||||
NewContent: content,
|
NewDescription: content,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := kanban.CreateCard(args); err != nil {
|
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) {
|
return func(t *testing.T) {
|
||||||
t.Log("When a card is read from the database.")
|
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)
|
t.Logf("%s\tExpected card title received, got: %s.", success, card.Title)
|
||||||
}
|
}
|
||||||
|
|
||||||
if card.Content != wantContent {
|
if card.Description != wantDescription {
|
||||||
t.Errorf("%s\tUnexpected card content received, want: %s, got: %s.", failure, wantContent, card.Content)
|
t.Errorf("%s\tUnexpected card content received, want: %s, got: %s.", failure, wantDescription, card.Description)
|
||||||
} else {
|
} 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 {
|
if card.Created != wantTimestamp {
|
||||||
|
@ -124,7 +124,7 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
|
||||||
CardID: cardID,
|
CardID: cardID,
|
||||||
CardArgs: board.CardArgs{
|
CardArgs: board.CardArgs{
|
||||||
NewTitle: newTitle,
|
NewTitle: newTitle,
|
||||||
NewContent: newContent,
|
NewDescription: newContent,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
|
||||||
want := board.Card{
|
want := board.Card{
|
||||||
ID: cardID,
|
ID: cardID,
|
||||||
Title: newTitle,
|
Title: newTitle,
|
||||||
Content: newContent,
|
Description: newContent,
|
||||||
Created: timestamp,
|
Created: timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newCon
|
||||||
CardID: cardID,
|
CardID: cardID,
|
||||||
CardArgs: board.CardArgs{
|
CardArgs: board.CardArgs{
|
||||||
NewTitle: "",
|
NewTitle: "",
|
||||||
NewContent: newContent,
|
NewDescription: newContent,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newCon
|
||||||
want := board.Card{
|
want := board.Card{
|
||||||
ID: cardID,
|
ID: cardID,
|
||||||
Title: expectedTitle,
|
Title: expectedTitle,
|
||||||
Content: newContent,
|
Description: newContent,
|
||||||
Created: timestamp,
|
Created: timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ func testMoveCardToStatus(kanban board.Board) func(t *testing.T) {
|
||||||
|
|
||||||
title := "Test card."
|
title := "Test card."
|
||||||
|
|
||||||
cardArgs := board.CardArgs{NewTitle: title, NewContent: ""}
|
cardArgs := board.CardArgs{NewTitle: title, NewDescription: ""}
|
||||||
|
|
||||||
cardID, err := kanban.CreateCard(cardArgs)
|
cardID, err := kanban.CreateCard(cardArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -165,7 +165,7 @@ func TestReadAndWriteCards(t *testing.T) {
|
||||||
singleCard := board.Card{
|
singleCard := board.Card{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: "A test task.",
|
Title: "A test task.",
|
||||||
Content: "This task should be completed.",
|
Description: "This task should be completed.",
|
||||||
}
|
}
|
||||||
|
|
||||||
singleCardID := testWriteOneCard(t, database, singleCard)
|
singleCardID := testWriteOneCard(t, database, singleCard)
|
||||||
|
@ -175,17 +175,17 @@ func TestReadAndWriteCards(t *testing.T) {
|
||||||
{
|
{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: "Test card A.",
|
Title: "Test card A.",
|
||||||
Content: "This is test card A.",
|
Description: "This is test card A.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: "Test card B.",
|
Title: "Test card B.",
|
||||||
Content: "This is test card B.",
|
Description: "This is test card B.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: "Test card C.",
|
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{
|
want := board.Card{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Title: "A test task.",
|
Title: "A test task.",
|
||||||
Content: "This task should be completed.",
|
Description: "This task should be completed.",
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
|
@ -280,17 +280,17 @@ func testReadManyCards(t *testing.T, database *bolt.DB, cardIDs []int) {
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
Title: "Test card A.",
|
Title: "Test card A.",
|
||||||
Content: "This is test card A.",
|
Description: "This is test card A.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
Title: "Test card B.",
|
Title: "Test card B.",
|
||||||
Content: "This is test card B.",
|
Description: "This is test card B.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 4,
|
ID: 4,
|
||||||
Title: "Test card C.",
|
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{
|
card := board.Card{
|
||||||
ID: -1,
|
ID: -1,
|
||||||
Title: "Test card",
|
Title: "Test card",
|
||||||
Content: "",
|
Description: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
cardID, err := db.Write(database, db.CardBucket, &card)
|
cardID, err := db.Write(database, db.CardBucket, &card)
|
||||||
|
|
|
@ -220,7 +220,7 @@ func (u *UI) initQuitModal() {
|
||||||
func (u *UI) newCard(title, content string) error {
|
func (u *UI) newCard(title, content string) error {
|
||||||
args := board.CardArgs{
|
args := board.CardArgs{
|
||||||
NewTitle: title,
|
NewTitle: title,
|
||||||
NewContent: content,
|
NewDescription: content,
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := u.board.CreateCard(args); err != nil {
|
if _, err := u.board.CreateCard(args); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue