2021-02-10 01:00:02 +01:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-02-10 03:33:05 +01:00
|
|
|
"path"
|
2021-02-10 01:00:02 +01:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHappyGetPhoto(t *testing.T) {
|
|
|
|
_, err := Client.V1().GetPhoto(WellKnownPhotoID)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("expected success getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSadGetPhoto(t *testing.T) {
|
2021-02-10 03:33:05 +01:00
|
|
|
photo, err := Client.V1().GetPhoto(UnknownPhotoID)
|
2021-02-10 01:00:02 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Logf("success returning error for unknown photo: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Errorf("expected error for unknown photo: %s", photo.UUID)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHappyUpdatePhoto(t *testing.T) {
|
|
|
|
photo, err := Client.V1().GetPhoto(WellKnownPhotoID)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
photo.PhotoDescription = fmt.Sprintf("Sample App Description: %s", time.Now().String())
|
|
|
|
_, err = Client.V1().UpdatePhoto(photo)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error updating photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSadUpdatePhoto(t *testing.T) {
|
|
|
|
photo, err := Client.V1().GetPhoto(WellKnownPhotoID)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
return
|
|
|
|
}
|
2021-02-10 03:33:05 +01:00
|
|
|
photo.UUID = UnknownPhotoID
|
2021-02-10 01:00:02 +01:00
|
|
|
photo.PhotoDescription = fmt.Sprintf("Sample App Description: %s", time.Now().String())
|
|
|
|
photo, err = Client.V1().UpdatePhoto(photo)
|
|
|
|
if err != nil {
|
|
|
|
t.Logf("expecting failure at updating photo unknown photo: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
t.Errorf("expecting failure updaitng bad photo id: %s", photo.UUID)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2021-02-10 03:25:46 +01:00
|
|
|
|
|
|
|
func TestHappyGetPhotoDownload(t *testing.T) {
|
2021-02-10 03:33:05 +01:00
|
|
|
photo, err := Client.V1().GetPhoto(WellKnownPhotoID)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
file, err := Client.V1().GetPhotoDownload(WellKnownPhotoID)
|
2021-02-10 03:25:46 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("expected success getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2021-02-10 03:33:05 +01:00
|
|
|
for _, f := range photo.Files {
|
|
|
|
fileName := path.Base(f.FileName)
|
|
|
|
t.Logf("Downloaded [%s]", fileName)
|
|
|
|
t.Logf("Photo Bytes: %d", len(file))
|
|
|
|
}
|
2021-02-10 03:25:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSadGetPhotoDownload(t *testing.T) {
|
2021-02-10 03:33:05 +01:00
|
|
|
_, err := Client.V1().GetPhotoDownload(UnknownPhotoID)
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("expected failure getting well known photo: %v", err)
|
|
|
|
t.FailNow()
|
2021-02-10 03:25:46 +01:00
|
|
|
}
|
|
|
|
}
|