-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from GenerateNU/36-cc-15-update-gift-type-and-…
…testing cc 15 update gift type and testing
- Loading branch information
Showing
9 changed files
with
83 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,13 @@ package tests | |
|
||
import ( | ||
"CaitsCurates/backend/src/model" | ||
"github.com/stretchr/testify/assert" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/lib/pq" | ||
"gorm.io/driver/postgres" | ||
"gorm.io/gorm" | ||
) | ||
|
@@ -52,7 +54,7 @@ func TestGiftModel(t *testing.T) { | |
defer tx.Rollback() | ||
|
||
// Create Gift | ||
gift := model.Gift{Name: "Super cool new toy", Price: 500000.00, Link: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", Description: "Really great content. Highly recommend", Demographic: "Unknown..."} | ||
gift := model.Gift{Name: "Super cool new toy", Price: 500000.00, Link: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", Description: "Really great content. Highly recommend", Demographic: "Unknown...", Category: pq.StringArray{"Best selling"}} | ||
|
||
err = tx.Create(&gift).Error | ||
assert.NoError(t, err) | ||
|
@@ -68,6 +70,7 @@ func TestGiftModel(t *testing.T) { | |
assert.Equal(t, gift.Description, fetchedGift.Description) | ||
assert.Equal(t, gift.Demographic, fetchedGift.Demographic) | ||
assert.Equal(t, gift.Link, fetchedGift.Link) | ||
assert.Equal(t, gift.Category, fetchedGift.Category) | ||
assert.Equal(t, gift.CreatedAt.In(time.UTC).Round(time.Millisecond), | ||
fetchedGift.CreatedAt.In(time.UTC).Round(time.Millisecond)) | ||
|
||
|
@@ -117,7 +120,7 @@ func TestGiftRequestModel(t *testing.T) { | |
assert.NoError(t, err) | ||
|
||
// Create GiftRequest | ||
giftRequest := model.GiftRequest{GiftResponse: &giftResponse} | ||
giftRequest := model.GiftRequest{GiftResponse: &giftResponse, Occasion: pq.StringArray{"Birthday"}, RecipientInterests: pq.StringArray{"Soccer"}} | ||
user := model.User{Email: "[email protected]", FirstName: "person1", LastName: "lastname1", Password: "dgeeg32"} | ||
customer := model.Customer{GiftRequests: []*model.GiftRequest{&giftRequest}, User: user} | ||
err = tx.Create(&customer).Error | ||
|
@@ -146,6 +149,8 @@ func TestGiftRequestModel(t *testing.T) { | |
assert.NoError(t, err) | ||
assert.Equal(t, giftRequest.ID, fetchedGiftRequest.ID) | ||
assert.Equal(t, giftRequest.GiftResponseID, fetchedGiftRequest.GiftResponseID) | ||
assert.Equal(t, giftRequest.Occasion, fetchedGiftRequest.Occasion) | ||
assert.Equal(t, giftRequest.RecipientInterests, fetchedGiftRequest.RecipientInterests) | ||
assert.Equal(t, giftRequest.CreatedAt.In(time.UTC).Round(time.Millisecond), | ||
fetchedGiftRequest.CreatedAt.In(time.UTC).Round(time.Millisecond)) | ||
|
||
|
@@ -257,6 +262,7 @@ func TestGiftResponseModel(t *testing.T) { | |
Link: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", | ||
Description: "Really great content. Highly recommend", | ||
Demographic: "Unknown...", | ||
Category: pq.StringArray{"Best selling"}, | ||
GiftCollections: nil, | ||
} | ||
|
||
|
@@ -266,6 +272,7 @@ func TestGiftResponseModel(t *testing.T) { | |
Link: "https://www.youtube.com/Penguinz0", | ||
Description: "Really great content. Highly recommend", | ||
Demographic: "Unknown...", | ||
Category: pq.StringArray{"Best selling"}, | ||
GiftCollections: nil, | ||
} | ||
|
||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
export interface Gift { | ||
ID : number | ||
Name: string; | ||
Price: number; | ||
Link: string; | ||
Description: string; | ||
Demographic: string; | ||
GiftCollections: GiftCollection[]; | ||
ID: number; | ||
Name: string; | ||
Price: number; | ||
Link: string; | ||
Occasion: string; | ||
Description: string; | ||
Demographic: string; | ||
GiftCollections: GiftCollection[]; | ||
Category: string[]; | ||
} | ||
|
||
export interface GiftRequest { | ||
ID : number | ||
CustomerId: number; | ||
GiftResponseId: number | null; | ||
RecipientName: string; | ||
RecipientAge: number; | ||
Occasion: string[]; | ||
RecipientInterests: string[]; | ||
BudgetMax: number; | ||
BudgetMin: number; | ||
GiftResponse: GiftResponse | null; | ||
DateNeeded: string; | ||
ID: number; | ||
CustomerId: number; | ||
GiftResponseId: number | null; | ||
RecipientName: string; | ||
RecipientAge: number; | ||
Occasion: string[]; | ||
RecipientInterests: string[]; | ||
BudgetMax: number; | ||
BudgetMin: number; | ||
GiftResponse: GiftResponse | null; | ||
DateNeeded: string; | ||
} | ||
|
||
export interface GiftCollection { | ||
ID : number | ||
CustomerId: number | null; | ||
Customer: Customer; | ||
CollectionName: string; | ||
Gifts: Gift[]; | ||
ID: number; | ||
CustomerId: number | null; | ||
Customer: Customer; | ||
CollectionName: string; | ||
Gifts: Gift[]; | ||
} | ||
|
||
export interface GiftResponse { | ||
ID : number | ||
GiftCollection: GiftCollection; | ||
GiftCollectionId: number; | ||
CustomMessage: string; | ||
ID: number; | ||
GiftCollection: GiftCollection; | ||
GiftCollectionId: number; | ||
CustomMessage: string; | ||
} | ||
|
||
export interface User { | ||
ID : number | ||
Email: string; | ||
FirstName: string; | ||
LastName: string; | ||
Password: string; | ||
ID: number; | ||
Email: string; | ||
FirstName: string; | ||
LastName: string; | ||
Password: string; | ||
} | ||
|
||
export interface Customer { | ||
ID : number | ||
UserId: number; | ||
ID: number; | ||
UserId: number; | ||
} | ||
|
||
export interface Admin { | ||
ID : number | ||
UserId: number; | ||
} | ||
ID: number; | ||
UserId: number; | ||
} |