diff --git a/internal/api/config_test.go b/internal/api/config_test.go index 0258c66bc..d9939b399 100644 --- a/internal/api/config_test.go +++ b/internal/api/config_test.go @@ -19,3 +19,21 @@ func TestGetConfig(t *testing.T) { assert.Equal(t, http.StatusOK, r.Code) }) } + +func TestGetConfigOptions(t *testing.T) { + t.Run("unauthorised", func(t *testing.T) { + app, router, _ := NewApiTest() + GetConfigOptions(router) + r := PerformRequest(app, "GET", "/api/v1/config/options") + assert.Equal(t, http.StatusUnauthorized, r.Code) + }) +} + +func TestSaveConfigOptions(t *testing.T) { + t.Run("unauthorised", func(t *testing.T) { + app, router, _ := NewApiTest() + SaveConfigOptions(router) + r := PerformRequest(app, "POST", "/api/v1/config/options") + assert.Equal(t, http.StatusUnauthorized, r.Code) + }) +} diff --git a/internal/api/covers_test.go b/internal/api/covers_test.go index 4102efa89..a59815942 100644 --- a/internal/api/covers_test.go +++ b/internal/api/covers_test.go @@ -24,9 +24,15 @@ func TestAlbumCover(t *testing.T) { t.Run("album: could not find original", func(t *testing.T) { app, router, conf := NewApiTest() AlbumCover(router) - r := PerformRequest(app, "GET", "/api/v1/albums/at9lxuqxpogaaba8/t/"+conf.PreviewToken()+"/tile_500") + r := PerformRequest(app, "GET", "/api/v1/albums/at9lxuqxpogaaba9/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) + t.Run("invalid token", func(t *testing.T) { + app, router, _ := NewApiTest() + AlbumCover(router) + r := PerformRequest(app, "GET", "/api/v1/albums/at9lxuqxpogaaba8/t/xxx/tile_500") + assert.Equal(t, http.StatusForbidden, r.Code) + }) } func TestLabelCover(t *testing.T) { @@ -46,7 +52,15 @@ func TestLabelCover(t *testing.T) { t.Run("could not find original", func(t *testing.T) { app, router, conf := NewApiTest() LabelCover(router) - r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c3/t/"+conf.PreviewToken()+"/tile_500") + //r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c3/t/"+conf.PreviewToken()+"/tile_500") + //lt9k3pw1wowuy3c2 + r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c2/t/"+conf.PreviewToken()+"/tile_500") assert.Equal(t, http.StatusOK, r.Code) }) + t.Run("invalid token", func(t *testing.T) { + app, router, _ := NewApiTest() + LabelCover(router) + r := PerformRequest(app, "GET", "/api/v1/labels/lt9k3pw1wowuy3c3/t/xxx/tile_500") + assert.Equal(t, http.StatusForbidden, r.Code) + }) } diff --git a/internal/api/file_delete_test.go b/internal/api/file_delete_test.go index 81ff65703..19003dafc 100644 --- a/internal/api/file_delete_test.go +++ b/internal/api/file_delete_test.go @@ -16,12 +16,20 @@ func TestDeleteFile(t *testing.T) { r := PerformRequest(app, "DELETE", "/api/v1/photos/5678/files/23456hbg") assert.Equal(t, http.StatusNotFound, r.Code) }) - /*t.Run("delete primary file", func(t *testing.T) { + t.Run("delete primary file", func(t *testing.T) { app, router, _ := NewApiTest() DeleteFile(router) r := PerformRequest(app, "DELETE", "/api/v1/photos/pt9jtdre2lvl0yh7/files/ft8es39w45bnlqdw") + assert.Equal(t, http.StatusInternalServerError, r.Code) + }) + t.Run("try to delete file", func(t *testing.T) { + app, router, _ := NewApiTest() + + DeleteFile(router) + + r := PerformRequest(app, "DELETE", "/api/v1/photos/pt9jtdre2lvl0yh8/files/ft9es39w45bnlqdw") assert.Equal(t, http.StatusNotFound, r.Code) - })*/ + }) } diff --git a/pkg/txt/time_test.go b/pkg/txt/time_test.go index 80804cecf..660707a8a 100644 --- a/pkg/txt/time_test.go +++ b/pkg/txt/time_test.go @@ -233,6 +233,14 @@ func TestTime(t *testing.T) { result := Time("2020-01-00.jpg") assert.Equal(t, "0001-01-01 00:00:00 +0000 UTC", result.String()) }) + t.Run("IMG-20191120-WA0001.jpg", func(t *testing.T) { + result := Time("IMG-20191120-WA0001.jpg") + assert.Equal(t, "0001-01-01 00:00:00 +0000 UTC", result.String()) + }) + t.Run("VID-20191120-WA0001.jpg", func(t *testing.T) { + result := Time("VID-20191120-WA0001.jpg") + assert.Equal(t, "0001-01-01 00:00:00 +0000 UTC", result.String()) + }) } func TestIsTime(t *testing.T) {