+api doc, fixed endpoints

This commit is contained in:
2023-03-23 17:02:32 +01:00
parent 0ed15a265d
commit 3fb66e075d
4 changed files with 100 additions and 26 deletions

View File

@@ -164,7 +164,7 @@ func HandleResponse(c *cfg.Config, resp *req.Response) error {
func UploadFiles(w io.Writer, c *cfg.Config, args []string) error {
// setup url, req.Request, timeout handling etc
rq := Setup(c, "/file/")
rq := Setup(c, "/uploads/")
// collect files to upload from @argv
if err := GatherFiles(rq, args); err != nil {
@@ -220,7 +220,7 @@ func List(w io.Writer, c *cfg.Config, args []string) error {
func Delete(w io.Writer, c *cfg.Config, args []string) error {
for _, id := range args {
rq := Setup(c, "/file/"+id+"/")
rq := Setup(c, "/uploads/"+id+"/")
resp, err := rq.R.Delete(rq.Url)
@@ -266,7 +266,7 @@ func Download(w io.Writer, c *cfg.Config, args []string) error {
id := args[0]
rq := Setup(c, "/file/"+id+"/")
rq := Setup(c, "/uploads/"+id+"/")
if !c.Silent {
// progres bar

View File

@@ -111,7 +111,7 @@ func TestUploadFiles(t *testing.T) {
name: "upload-file",
apikey: "token",
wantfail: false,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: `{"success": true}`,
files: []string{"../t/t1"}, // pwd is lib/ !
@@ -121,7 +121,7 @@ func TestUploadFiles(t *testing.T) {
name: "upload-dir",
apikey: "token",
wantfail: false,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: `{"success": true}`,
files: []string{"../t"}, // pwd is lib/ !
@@ -131,7 +131,7 @@ func TestUploadFiles(t *testing.T) {
name: "upload-catch-nonexistent-file",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: `{"success": false}`,
files: []string{"../t/none"},
@@ -141,7 +141,7 @@ func TestUploadFiles(t *testing.T) {
name: "upload-catch-no-access",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 403,
sendjson: `{"success": false}`,
files: []string{"../t/t1"},
@@ -151,7 +151,7 @@ func TestUploadFiles(t *testing.T) {
name: "upload-check-output",
apikey: "token",
wantfail: false,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: `{"uploads":[
{
@@ -313,7 +313,7 @@ func TestDelete(t *testing.T) {
name: "delete",
apikey: "token",
wantfail: false,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: `{"success":true,"message":"","code":200}`,
files: []string{"cc2c965a"},
@@ -324,7 +324,7 @@ func TestDelete(t *testing.T) {
name: "delete-catch-empty-json",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendjson: "",
files: []string{"cc2c965a"},
@@ -334,7 +334,7 @@ func TestDelete(t *testing.T) {
name: "delete-catch-no-access",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 503,
sendjson: listingnoaccess,
files: []string{"cc2c965a"},
@@ -365,7 +365,7 @@ func TestDownload(t *testing.T) {
name: "download",
apikey: "token",
wantfail: false,
route: "/file/",
route: "/uploads/",
sendcode: 200,
sendfile: "../t/t1",
files: []string{"cc2c965a"},
@@ -376,7 +376,7 @@ func TestDownload(t *testing.T) {
name: "download-catch-empty-response",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 200,
files: []string{"cc2c965a"},
method: "GET",
@@ -385,7 +385,7 @@ func TestDownload(t *testing.T) {
name: "download-catch-no-access",
apikey: "token",
wantfail: true,
route: "/file/",
route: "/uploads/",
sendcode: 503,
sendjson: listingnoaccess,
files: []string{"cc2c965a"},