Created
July 16, 2024 16:21
-
-
Save BK1031/8a7e0d30cdd71b76e449369daceb1e01 to your computer and use it in GitHub Desktop.
singlestore-go-bookstore TestDeleteOrder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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