Skip to content

Instantly share code, notes, and snippets.

@BK1031
Created July 16, 2024 16:21
Show Gist options
  • Save BK1031/8a7e0d30cdd71b76e449369daceb1e01 to your computer and use it in GitHub Desktop.
Save BK1031/8a7e0d30cdd71b76e449369daceb1e01 to your computer and use it in GitHub Desktop.
singlestore-go-bookstore TestDeleteOrder
func TestDeleteOrder(t *testing.T) {
ResetOrderTable()
ResetBookTable()
// Arrange
gatsby, _ := CreateBook(model.Book{
Title: "The Great Gatsby",
Author: "F. Scott Fitzgerald",
Price: 29.99,
Genre: "Fiction",
})
order, _ := CreateOrder(model.Order{
Items: []model.OrderItem{
{
BookID: gatsby.ID,
Quantity: 2,
},
},
})
t.Run("Success", func(t *testing.T) {
// Act
err := DeleteOrder(order)
// Assert
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
})
t.Run("Error", func(t *testing.T) {
// Act
err := DeleteOrder(model.Order{})
// Assert
if err == nil {
t.Errorf("Expected error, got nil")
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment