mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-18 13:01:13 +01:00
more tests and db fixes
This commit is contained in:
@@ -111,7 +111,7 @@ func TestUploadFiles(t *testing.T) {
|
||||
name: "upload-file",
|
||||
apikey: "token",
|
||||
wantfail: false,
|
||||
route: "/uploads/",
|
||||
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: "/uploads/",
|
||||
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: "/uploads/",
|
||||
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: "/uploads/",
|
||||
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: "/uploads/",
|
||||
route: "/uploads",
|
||||
sendcode: 200,
|
||||
sendjson: `{"uploads":[
|
||||
{
|
||||
@@ -266,7 +266,7 @@ func TestDescribe(t *testing.T) {
|
||||
sendjson: listing,
|
||||
files: []string{"cc2c965a"},
|
||||
method: "GET",
|
||||
expect: `Uploaded: 2023-03-21 12:06:54.890501888`,
|
||||
expect: `Created: 2023-03-21 12:06:54.890501888`,
|
||||
},
|
||||
{
|
||||
name: "describe-catch-empty-json",
|
||||
@@ -292,7 +292,7 @@ func TestDescribe(t *testing.T) {
|
||||
|
||||
for _, unit := range tests {
|
||||
var w bytes.Buffer
|
||||
unit.route += unit.files[0] + "/"
|
||||
unit.route += unit.files[0]
|
||||
Intercept(unit)
|
||||
Check(t, unit, &w, Describe(&w, conf, unit.files))
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ func WriteExtended(w io.Writer, response *common.Response) {
|
||||
|
||||
// we shall only have 1 element, however, if we ever support more, here we go
|
||||
for _, entry := range response.Uploads {
|
||||
expire := prepareExpire(entry.Expire, entry.Uploaded)
|
||||
expire := prepareExpire(entry.Expire, entry.Created)
|
||||
fmt.Fprintf(w, format, "Id", entry.Id)
|
||||
fmt.Fprintf(w, format, "Expire", expire)
|
||||
fmt.Fprintf(w, format, "Context", entry.Context)
|
||||
fmt.Fprintf(w, format, "Uploaded", entry.Uploaded)
|
||||
fmt.Fprintf(w, format, "Created", entry.Created)
|
||||
fmt.Fprintf(w, format, "Filename", entry.File)
|
||||
fmt.Fprintf(w, format, "Url", entry.Url)
|
||||
fmt.Fprintln(w)
|
||||
@@ -120,11 +120,11 @@ func UploadsRespondTable(w io.Writer, resp *req.Response) error {
|
||||
data := [][]string{}
|
||||
for _, entry := range response.Uploads {
|
||||
data = append(data, []string{
|
||||
entry.Id, entry.Expire, entry.Context, entry.Uploaded.Format("2006-01-02 15:04:05"),
|
||||
entry.Id, entry.Expire, entry.Context, entry.Created.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
WriteTable(w, []string{"ID", "EXPIRE", "CONTEXT", "UPLOADED"}, data)
|
||||
WriteTable(w, []string{"ID", "EXPIRE", "CONTEXT", "CREATED"}, data)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user