Compare commits

..

No commits in common. "af7f12061644c0463eb51cec4d6f8a922f33c9bf" and "2e80c049179ed07a583fedb31bf2d1e631db29de" have entirely different histories.

3 changed files with 6 additions and 21 deletions

View file

@ -5,7 +5,6 @@ import (
"encoding/gob"
"fmt"
"sort"
"time"
"codeflow.dananglin.me.uk/apollo/pelican/internal/db"
bolt "go.etcd.io/bbolt"
@ -206,8 +205,6 @@ type CardArgs struct {
// CreateCard creates a card in the database.
func (b *Board) CreateCard(args CardArgs) (int, error) {
timestamp := time.Now().Format(time.DateOnly)
statusList, err := b.StatusList()
if err != nil {
return 0, fmt.Errorf("unable to read the status list, %w", err)
@ -221,7 +218,6 @@ func (b *Board) CreateCard(args CardArgs) (int, error) {
ID: -1,
Title: args.NewTitle,
Content: args.NewContent,
Created: timestamp,
}
cardID, err := db.Write(b.db, db.CardBucket, &card)

View file

@ -15,7 +15,6 @@ type Card struct {
ID int
Title string
Content string
Created string
}
// UpdateId updates the ID of the Card value.

View file

@ -6,7 +6,6 @@ import (
"path/filepath"
"reflect"
"testing"
"time"
"codeflow.dananglin.me.uk/apollo/pelican/internal/board"
)
@ -35,20 +34,19 @@ 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)
t.Run("Test Create Card", testCreateCard(kanban, initialCardTitle, initialCardContent, expectedCardID, expectedStatusID))
t.Run("Test Read Card", testReadCard(kanban, expectedCardID, initialCardTitle, initialCardContent, timestamp))
t.Run("Test Read Card", testReadCard(kanban, expectedCardID, initialCardTitle, initialCardContent))
modifiedCardTitle := "Test card updated."
modifiedCardContent1 := "Ensure that this card is safely updated in the database."
t.Run("Test Update Card", testUpdateCard(kanban, expectedCardID, modifiedCardTitle, modifiedCardContent1, timestamp))
t.Run("Test Update Card", testUpdateCard(kanban, expectedCardID, modifiedCardTitle, modifiedCardContent1))
modifiedCardContent2 := "Updated card content only."
t.Run("Test Update Card Content", testUpdateCardContent(kanban, expectedCardID, modifiedCardTitle, modifiedCardContent2, timestamp))
t.Run("Test Update Card Content", testUpdateCardContent(kanban, expectedCardID, modifiedCardTitle, modifiedCardContent2))
t.Run("Test Card Delete", testDeleteCard(kanban, expectedCardID, expectedStatusID))
}
@ -87,7 +85,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, wantContent string) func(t *testing.T) {
return func(t *testing.T) {
t.Log("When a card is read from the database.")
@ -107,16 +105,10 @@ func testReadCard(kanban board.Board, cardID int, wantTitle, wantContent, wantTi
} else {
t.Logf("%s\tExpected card content received, got: %s.", success, card.Content)
}
if card.Created != wantTimestamp {
t.Errorf("%s\tUnexpected timestamp received for the created card, want: %s, got %s.", failure, wantTimestamp, card.Created)
} else {
t.Logf("%s\tExpected timestamp received for the created card, got: %s.", success, card.Created)
}
}
}
func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timestamp string) func(t *testing.T) {
func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent string) func(t *testing.T) {
return func(t *testing.T) {
t.Log("When a card is updated in the database.")
@ -141,7 +133,6 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
ID: cardID,
Title: newTitle,
Content: newContent,
Created: timestamp,
}
if !reflect.DeepEqual(got, want) {
@ -152,7 +143,7 @@ func testUpdateCard(kanban board.Board, cardID int, newTitle, newContent, timest
}
}
func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newContent, timestamp string) func(t *testing.T) {
func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newContent string) func(t *testing.T) {
return func(t *testing.T) {
t.Log("When (and only when) a card's content is updated in the database.")
@ -177,7 +168,6 @@ func testUpdateCardContent(kanban board.Board, cardID int, expectedTitle, newCon
ID: cardID,
Title: expectedTitle,
Content: newContent,
Created: timestamp,
}
if !reflect.DeepEqual(got, want) {