Working photo and album endpoints with super amazing unit and itnegrations tests - please run my fucking code i dare you
Signed-off-by: Kris Nóva <kris@nivenly.com>main
parent
194f0acb28
commit
c78e3d199e
|
@ -146,6 +146,6 @@ func (v1 *V1Client) DeletePhotosFromAlbum(albumUUID string, photoIDs []string) e
|
||||||
func (v1 *V1Client) GetAlbumDownload(uuid string) ([]byte, error) {
|
func (v1 *V1Client) GetAlbumDownload(uuid string) ([]byte, error) {
|
||||||
// NOTE: Even though this method is singular GetAlbum
|
// NOTE: Even though this method is singular GetAlbum
|
||||||
// if will call the "albums" plural endpoint.
|
// if will call the "albums" plural endpoint.
|
||||||
resp := v1.GET("/api/v1/albums/%s", uuid)
|
resp := v1.GET("/api/v1/albums/%s?t=%s", uuid, v1.downloadToken)
|
||||||
return resp.Body, resp.Error
|
return resp.Body, resp.Error
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,4 @@ Order: oldest
|
||||||
Country: zz
|
Country: zz
|
||||||
CreatedAt: 2021-02-12T00:42:10Z
|
CreatedAt: 2021-02-12T00:42:10Z
|
||||||
UpdatedAt: 2021-02-12T00:42:10Z
|
UpdatedAt: 2021-02-12T00:42:10Z
|
||||||
Photos:
|
DeletedAt: 2021-02-12T01:19:49.19521169Z
|
||||||
- UID: pqnzigq351j2fqgn
|
|
||||||
CreatedAt: 2021-02-12T00:42:09.791065836Z
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe68w1gxzard2c
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:17:21Z
|
||||||
|
UpdatedAt: 2021-02-12T01:17:21Z
|
||||||
|
DeletedAt: 2021-02-12T01:17:20.582731838Z
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe68w1lzpyk5zg
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:17:21Z
|
||||||
|
UpdatedAt: 2021-02-12T01:17:21Z
|
||||||
|
DeletedAt: 2021-02-12T01:17:20.549276966Z
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe68w245je8zni
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:17:21Z
|
||||||
|
UpdatedAt: 2021-02-12T01:17:21Z
|
||||||
|
DeletedAt: 2021-02-12T01:17:20.626364883Z
|
|
@ -0,0 +1,10 @@
|
||||||
|
UID: aqoe68wxhb91hvje
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Description: An updated album description
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:17:20Z
|
||||||
|
UpdatedAt: 2021-02-12T01:17:20.480072684Z
|
||||||
|
DeletedAt: 2021-02-12T01:17:20.493622671Z
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe6k91z2qayg4w
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:24:10Z
|
||||||
|
UpdatedAt: 2021-02-12T01:24:10Z
|
||||||
|
DeletedAt: 2021-02-12T01:24:09.719043974Z
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe6k922s2v6yp1
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:24:10Z
|
||||||
|
UpdatedAt: 2021-02-12T01:24:10Z
|
||||||
|
DeletedAt: 2021-02-12T01:24:09.794949796Z
|
|
@ -0,0 +1,10 @@
|
||||||
|
UID: aqoe6k93d879bjgg
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Description: An updated album description
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:24:10Z
|
||||||
|
UpdatedAt: 2021-02-12T01:24:09.652930019Z
|
||||||
|
DeletedAt: 2021-02-12T01:24:09.664933038Z
|
|
@ -0,0 +1,9 @@
|
||||||
|
UID: aqoe6k9k0kkmx79g
|
||||||
|
Slug: testalbum
|
||||||
|
Type: album
|
||||||
|
Title: TestAlbum
|
||||||
|
Order: oldest
|
||||||
|
Country: zz
|
||||||
|
CreatedAt: 2021-02-12T01:24:10Z
|
||||||
|
UpdatedAt: 2021-02-12T01:24:10Z
|
||||||
|
DeletedAt: 2021-02-12T01:24:09.744169818Z
|
|
@ -314,6 +314,11 @@
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
"expiration": 1613686778812288997
|
"expiration": 1613686778812288997
|
||||||
},
|
},
|
||||||
|
"5e45fef754afe86cd06fdece3654e1d096844e9bb06e656a": {
|
||||||
|
"user": "uqnzie01i1nypnt9",
|
||||||
|
"tokens": null,
|
||||||
|
"expiration": 1613697849631150727
|
||||||
|
},
|
||||||
"5fccb8ed1ac9f5ca4152b071128078b3da8810e88c1d9728": {
|
"5fccb8ed1ac9f5ca4152b071128078b3da8810e88c1d9728": {
|
||||||
"user": "uqnzie01i1nypnt9",
|
"user": "uqnzie01i1nypnt9",
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
|
@ -539,6 +544,11 @@
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
"expiration": 1613513937752119685
|
"expiration": 1613513937752119685
|
||||||
},
|
},
|
||||||
|
"a195acf32c21a87fc81c92363ed95faaa01abfc91b481179": {
|
||||||
|
"user": "uqnzie01i1nypnt9",
|
||||||
|
"tokens": null,
|
||||||
|
"expiration": 1613697851138920617
|
||||||
|
},
|
||||||
"a3139951989d33f77e643cf68bdd8e2c7cbb88f344200903": {
|
"a3139951989d33f77e643cf68bdd8e2c7cbb88f344200903": {
|
||||||
"user": "uqnzie01i1nypnt9",
|
"user": "uqnzie01i1nypnt9",
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
|
@ -714,6 +724,11 @@
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
"expiration": 1613514516062495823
|
"expiration": 1613514516062495823
|
||||||
},
|
},
|
||||||
|
"dd302423a35c910b5cd65027f2fba9edb7efbf0ee0f81157": {
|
||||||
|
"user": "uqnzie01i1nypnt9",
|
||||||
|
"tokens": null,
|
||||||
|
"expiration": 1613697440458652837
|
||||||
|
},
|
||||||
"e089dfbed493744e24c0cdf9be5f06c81979a17e166d098c": {
|
"e089dfbed493744e24c0cdf9be5f06c81979a17e166d098c": {
|
||||||
"user": "uqnzie01i1nypnt9",
|
"user": "uqnzie01i1nypnt9",
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
|
@ -764,6 +779,11 @@
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
"expiration": 1613512474632135880
|
"expiration": 1613512474632135880
|
||||||
},
|
},
|
||||||
|
"eed103dd37ee5347149d459bfb393d682416adceb8da887e": {
|
||||||
|
"user": "uqnzie01i1nypnt9",
|
||||||
|
"tokens": null,
|
||||||
|
"expiration": 1613697441816718340
|
||||||
|
},
|
||||||
"f27ef3af1a5139eb23ab2d2cd5adb54dd63e147c74f12208": {
|
"f27ef3af1a5139eb23ab2d2cd5adb54dd63e147c74f12208": {
|
||||||
"user": "uqnzie01i1nypnt9",
|
"user": "uqnzie01i1nypnt9",
|
||||||
"tokens": null,
|
"tokens": null,
|
||||||
|
|
Binary file not shown.
|
@ -3,7 +3,7 @@ UID: pqnzigq351j2fqgn
|
||||||
Type: image
|
Type: image
|
||||||
Title: A really great photo!
|
Title: A really great photo!
|
||||||
TitleSrc: manual
|
TitleSrc: manual
|
||||||
Description: 'Sample App Description: 2021-02-11 17:16:03.257337568 -0800 PST m=+6.449998955'
|
Description: 'Sample App Description: 2021-02-11 17:24:09.899837223 -0800 PST m=+6.509602721'
|
||||||
DescriptionSrc: manual
|
DescriptionSrc: manual
|
||||||
OriginalName: IMG_3044
|
OriginalName: IMG_3044
|
||||||
Year: -1
|
Year: -1
|
||||||
|
@ -13,5 +13,5 @@ Details:
|
||||||
Keywords: green, tambourine
|
Keywords: green, tambourine
|
||||||
KeywordsSrc: manual
|
KeywordsSrc: manual
|
||||||
CreatedAt: 2021-02-04T03:17:14.613092062Z
|
CreatedAt: 2021-02-04T03:17:14.613092062Z
|
||||||
UpdatedAt: 2021-02-12T01:16:03.266957884Z
|
UpdatedAt: 2021-02-12T01:24:09.908530756Z
|
||||||
EditedAt: 2021-02-12T01:16:03Z
|
EditedAt: 2021-02-12T01:24:10Z
|
||||||
|
|
|
@ -179,74 +179,91 @@ func TestSadCloneAlbum(t *testing.T) {
|
||||||
|
|
||||||
// TestAlbumAddDeletePhoto is a giant integration test
|
// TestAlbumAddDeletePhoto is a giant integration test
|
||||||
// that will exercise many methods in the SDK
|
// that will exercise many methods in the SDK
|
||||||
//func TestAlbumAddDeletePhoto(t *testing.T) {
|
|
||||||
// album := api.Album{
|
|
||||||
// AlbumTitle: WellKnownAlbumTitle,
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// newAlbum, err := Client.V1().CreateAlbum(album)
|
// This is the most complete integration test in the suite
|
||||||
// if err != nil {
|
// and is the test that will also exercise adding and deleting
|
||||||
// t.Errorf("expected success creating album: %v", err)
|
// photos from an album
|
||||||
// t.FailNow()
|
func TestAlbumAddDeletePhoto(t *testing.T) {
|
||||||
// }
|
album := api.Album{
|
||||||
//
|
AlbumTitle: WellKnownAlbumTitle,
|
||||||
// // Add Photos
|
}
|
||||||
// photos := []string{
|
|
||||||
// WellKnownPhotoID,
|
|
||||||
// }
|
|
||||||
// err = Client.V1().AddPhotosToAlbum(newAlbum.AlbumUID, photos)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Errorf("expected to add photos to album: %v", err)
|
|
||||||
// // Note: We do NOT FailNow() here because we want to clean up
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Get the photos by album
|
|
||||||
// updatedPhotos, err := Client.V1().GetPhotos(&api.PhotoOptions{
|
|
||||||
// Count: 100,
|
|
||||||
// AlbumUID: newAlbum.AlbumUID,
|
|
||||||
// })
|
|
||||||
// if err != nil {
|
|
||||||
// t.Errorf("expecting to list photos by album: %v", err)
|
|
||||||
// // Note: We do NOT FailNow() here because we want to clean up
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// var updatedPhotoIDs []string
|
|
||||||
// for _, photo := range updatedPhotos {
|
|
||||||
// updatedPhotoIDs = append(updatedPhotoIDs, photo.PhotoUID)
|
|
||||||
// }
|
|
||||||
// if len(updatedPhotos) != 1 {
|
|
||||||
// t.Errorf("expecting 1 well known photo in album, found: %d", len(updatedPhotos))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// err = Client.V1().DeletePhotosFromAlbum(newAlbum.AlbumUID, updatedPhotoIDs)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Errorf("expected to delete newly created photos from album: %v", err)
|
|
||||||
// // Note: We do NOT FailNow() here because we want to clean up
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Get the photos by album
|
|
||||||
// updatedPhotos, err = Client.V1().GetPhotos(&api.PhotoOptions{
|
|
||||||
// Count: 100,
|
|
||||||
// AlbumUID: newAlbum.AlbumUID,
|
|
||||||
// })
|
|
||||||
// if err != nil {
|
|
||||||
// t.Errorf("expecting to list photos by album: %v", err)
|
|
||||||
// // Note: We do NOT FailNow() here because we want to clean up
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if len(updatedPhotos) != 0 {
|
|
||||||
// t.Errorf("expected empty album, found %d photos", len(updatedPhotos))
|
|
||||||
// // Note: We do NOT FailNow() here because we want to clean up
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// err = Client.V1().DeleteAlbums([]string{newAlbum.AlbumUID})
|
|
||||||
// if err != nil {
|
|
||||||
// t.Errorf("expected delete album %s, album not deleted: %v", newAlbum.AlbumUID, err)
|
|
||||||
// t.FailNow()
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// AddPhotosToAlbum
|
newAlbum, err := Client.V1().CreateAlbum(album)
|
||||||
// DeletePhotosFromAlbum
|
if err != nil {
|
||||||
|
t.Errorf("expected success creating album: %v", err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
|
||||||
// GetAlbumDownload
|
// Add Photos
|
||||||
|
photos := []string{
|
||||||
|
WellKnownPhotoID,
|
||||||
|
}
|
||||||
|
err = Client.V1().AddPhotosToAlbum(newAlbum.AlbumUID, photos)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expected to add photos to album: %v", err)
|
||||||
|
// Note: We do NOT FailNow() here because we want to clean up
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the photos by album
|
||||||
|
updatedPhotos, err := Client.V1().GetPhotos(&api.PhotoOptions{
|
||||||
|
Count: 100,
|
||||||
|
AlbumUID: newAlbum.AlbumUID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expecting to list photos by album: %v", err)
|
||||||
|
// Note: We do NOT FailNow() here because we want to clean up
|
||||||
|
}
|
||||||
|
|
||||||
|
var updatedPhotoIDs []string
|
||||||
|
for _, photo := range updatedPhotos {
|
||||||
|
updatedPhotoIDs = append(updatedPhotoIDs, photo.PhotoUID)
|
||||||
|
}
|
||||||
|
if len(updatedPhotos) != 1 {
|
||||||
|
t.Errorf("expecting 1 well known photo in album, found: %d", len(updatedPhotos))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = Client.V1().DeletePhotosFromAlbum(newAlbum.AlbumUID, updatedPhotoIDs)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expected to delete newly created photos from album: %v", err)
|
||||||
|
// Note: We do NOT FailNow() here because we want to clean up
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the photos by album
|
||||||
|
updatedPhotos, err = Client.V1().GetPhotos(&api.PhotoOptions{
|
||||||
|
Count: 100,
|
||||||
|
AlbumUID: newAlbum.AlbumUID,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expecting to list photos by album: %v", err)
|
||||||
|
// Note: We do NOT FailNow() here because we want to clean up
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(updatedPhotos) != 0 {
|
||||||
|
t.Errorf("expected empty album, found %d photos", len(updatedPhotos))
|
||||||
|
// Note: We do NOT FailNow() here because we want to clean up
|
||||||
|
}
|
||||||
|
|
||||||
|
err = Client.V1().DeleteAlbums([]string{newAlbum.AlbumUID})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expected delete album %s, album not deleted: %v", newAlbum.AlbumUID, err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHappyGetAlbumDownload(t *testing.T) {
|
||||||
|
// GetAlbumDownload should return a .zip file
|
||||||
|
bytes, err := Client.V1().GetAlbumDownload(WellKnownAlbumID)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("expecting album download: %v", err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
t.Logf("bytes of .zip file downloaded: %db", len(bytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSadGetAlbumDownload(t *testing.T) {
|
||||||
|
_, err := Client.V1().GetPhotoDownload(UnknownAlbumID)
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("expected failure getting well known album: %v", err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue