Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Chiefs
ChiefSend2
Commits
6fe86c61
Commit
6fe86c61
authored
Mar 23, 2021
by
Lukas Böhm
🎱
Browse files
small fixes
parent
085a3cba
Changes
4
Hide whitespace changes
Inline
Side-by-side
api/api.go
View file @
6fe86c61
...
...
@@ -37,7 +37,7 @@ func (fn endpointREST) ServeHTTP(w http.ResponseWriter, r *http.Request) {
//////////// routes /////////////
/////////////////////////////////
func
AllShares
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
*
HTTPError
{
func
AllShares
(
w
http
.
ResponseWriter
,
_
*
http
.
Request
)
*
HTTPError
{
fmt
.
Println
(
"AllShares"
)
db
,
err
:=
GetDatabase
()
if
err
!=
nil
{
...
...
@@ -56,9 +56,7 @@ func GetShare(w http.ResponseWriter, r *http.Request) *HTTPError {
fmt
.
Println
(
"Get Share"
)
vars
:=
mux
.
Vars
(
r
)
if
_
,
ok
:=
vars
[
"id"
];
!
ok
{
return
&
HTTPError
{
errors
.
New
(
"Invalid share ID"
),
"Invalid URL"
,
400
}
}
db
,
err
:=
GetDatabase
()
if
err
!=
nil
{
...
...
@@ -287,6 +285,9 @@ func SendJSON(w http.ResponseWriter, res interface{}) *HTTPError {
return
nil
}
func
SendMail
(
receiver
string
)
{
fmt
.
Println
(
"sending mail ...."
)
func
GetParam
(
vars
map
[
string
]
string
,
key
string
)
(
string
,
*
HTTPError
)
{
if
_
,
ok
:=
vars
[
key
];
!
ok
{
return
""
,
&
HTTPError
{
errors
.
New
(
"invalid URL param"
),
"Invalid URL"
,
400
}
}
return
vars
[
key
],
nil
}
api/api_test.go
View file @
6fe86c61
...
...
@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
...
...
@@ -120,30 +121,51 @@ func TestGetShare(t *testing.T) {
}
//func TestOpenShare(t *testing.T) {
// // Created
// b, _ := json.Marshal(Share {
// //ID: uuid.MustParse("e5134044-2704-4864-85be-318fb158009f"),
// Name: "TopKek",
// })
// read := strings.NewReader(string(b))
// // Sucessfully created
// res := DoRequest(t, "POST", "http://localhost:6969/shares", read, OpenShare, nil)
// assert.Equal(t, http.StatusCreated, res.Code)
// // Bad request
// res = DoRequest(t, "POST", "http://localhost:6969/shares", nil, OpenShare, nil)
// assert.Equal(t, http.StatusBadRequest, res.Code)
//}
//func TestCloseShare(t *testing.T) {
//
//}
//
//func TestUploadAttachment(t *testing.T) {
//
//}
//
//func TestDownloadFile(t *testing.T) {
//
//}
func
TestDownloadFile
(
t
*
testing
.
T
)
{
}
func
TestOpenShare
(
t
*
testing
.
T
)
{
// Created
b
,
_
:=
json
.
Marshal
(
Share
{
//ID: uuid.MustParse("e5134044-2704-4864-85be-318fb158009f"),
Name
:
"TopKek"
,
})
read
:=
strings
.
NewReader
(
string
(
b
))
// Sucessfully created
res
:=
DoRequest
(
t
,
"POST"
,
"http://localhost:6969/shares"
,
read
,
OpenShare
,
nil
)
assert
.
Equal
(
t
,
http
.
StatusCreated
,
res
.
Code
)
// Bad request
res
=
DoRequest
(
t
,
"POST"
,
"http://localhost:6969/shares"
,
nil
,
OpenShare
,
nil
)
assert
.
Equal
(
t
,
http
.
StatusBadRequest
,
res
.
Code
)
}
func
TestCloseShare
(
t
*
testing
.
T
)
{
t
.
Run
(
"happy path"
,
func
(
t
*
testing
.
T
)
{
})
t
.
Run
(
"not found"
,
func
(
t
*
testing
.
T
)
{
})
t
.
Run
(
"bad request"
,
func
(
t
*
testing
.
T
)
{
})
}
func
TestUploadAttachment
(
t
*
testing
.
T
)
{
t
.
Run
(
"happy path"
,
func
(
t
*
testing
.
T
)
{
})
t
.
Run
(
"not found"
,
func
(
t
*
testing
.
T
)
{
})
t
.
Run
(
"bad request"
,
func
(
t
*
testing
.
T
)
{
})
}
web/package-lock.json
View file @
6fe86c61
...
...
@@ -12,6 +12,7 @@
"axios": "^0.21.1",
"bootstrap": "^5.0.0-beta2",
"core-js": "^3.6.5",
"dayjs": "^1.10.4",
"filepond": "^4.25.1",
"filepond-plugin-file-validate-size": "^2.2.2",
"masonry-layout": "^4.2.2",
...
...
@@ -4500,6 +4501,11 @@
"node": ">=0.10"
}
},
"node_modules/dayjs": {
"version": "1.10.4",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz",
"integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw=="
},
"node_modules/de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
...
...
@@ -18046,6 +18052,11 @@
"assert-plus": "^1.0.0"
}
},
"dayjs": {
"version": "1.10.4",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz",
"integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw=="
},
"de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
...
...
web/package.json
View file @
6fe86c61
...
...
@@ -12,6 +12,7 @@
"axios"
:
"^0.21.1"
,
"bootstrap"
:
"^5.0.0-beta2"
,
"core-js"
:
"^3.6.5"
,
"dayjs"
:
"^1.10.4"
,
"filepond"
:
"^4.25.1"
,
"filepond-plugin-file-validate-size"
:
"^2.2.2"
,
"masonry-layout"
:
"^4.2.2"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment