package api import ( "net/http" "testing" "github.com/stretchr/testify/assert" ) func TestGetThumb(t *testing.T) { t.Run("invalid type", func(t *testing.T) { app, router, conf := NewApiTest() GetThumb(router) r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.PreviewToken()+"/xxx") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("invalid hash", func(t *testing.T) { app, router, conf := NewApiTest() GetThumb(router) r := PerformRequest(app, "GET", "/api/v1/t/1/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("could not find original", func(t *testing.T) { app, router, conf := NewApiTest() GetThumb(router) r := PerformRequest(app, "GET", "/api/v1/t/2cad9168fa6acc5c5c2965ddf6ec465ca42fd818/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) } func TestAlbumThumb(t *testing.T) { t.Run("invalid type", func(t *testing.T) { app, router, conf := NewApiTest() AlbumThumb(router) r := PerformRequest(app, "GET", "/api/v1/albums/at9lxuqxpogaaba7/t/"+conf.PreviewToken()+"/xxx") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("album has no photo (because is not existing)", func(t *testing.T) { app, router, conf := NewApiTest() AlbumThumb(router) r := PerformRequest(app, "GET", "/api/v1/albums/987-986435/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("album: could not find original", func(t *testing.T) { app, router, conf := NewApiTest() AlbumThumb(router) r := PerformRequest(app, "GET", "/api/v1/albums/at9lxuqxpogaaba8/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) } func TestLabelThumb(t *testing.T) { t.Run("invalid type", func(t *testing.T) { app, router, conf := NewApiTest() LabelThumb(router) r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c2/t/"+conf.PreviewToken()+"/xxx") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("invalid label", func(t *testing.T) { app, router, conf := NewApiTest() LabelThumb(router) r := PerformRequest(app, "GET", "/api/v1/labels/xxx/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) t.Run("could not find original", func(t *testing.T) { app, router, conf := NewApiTest() LabelThumb(router) r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c3/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) }