Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
stillasTracker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aleksander Aaboen
stillasTracker
Commits
7de9a693
Commit
7de9a693
authored
2 years ago
by
Martin Iversen
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/Martin' into Martin
parents
cf322d48
0f414f72
Branches
Branches containing commit
No related tags found
1 merge request
!114
Martin
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/tests/scaffolding_test.go
+19
-8
19 additions, 8 deletions
api/tests/scaffolding_test.go
with
19 additions
and
8 deletions
api/tests/scaffolding_test.go
+
19
−
8
View file @
7de9a693
package
tests
import
(
"github.com/gorilla/mux"
"github.com/steinfletcher/apitest"
"net/http"
"net/http/httptest"
"stillasTracker/api/endpoints"
"testing"
)
...
...
@@ -13,12 +15,15 @@ Function for testing the scaffolding endpoint
*/
func
Test_ScaffoldingAPITEST
(
t
*
testing
.
T
)
{
dataBaseTestConnection
()
handler
:=
http
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
r
:=
mux
.
NewRouter
(
)
//Add list of Scaffoldingparts which sends a post request and creates 12 scaffolding parts
t
.
Run
(
"Add list of Scaffoldingparts"
,
func
(
t
*
testing
.
T
)
{
r
.
HandleFunc
(
"/stillastracking/v1/api/unit/"
,
endpoints
.
ScaffoldingRequest
)
ts
:=
httptest
.
NewServer
(
r
)
defer
ts
.
Close
()
apitest
.
New
()
.
Handler
Func
(
handle
r
)
.
Handler
(
r
)
.
Post
(
"/stillastracking/v1/api/unit/"
)
.
Body
(
`[ { "id": 1, "type": "Spire", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address":null } }, { "id": 2, "type": "Flooring", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 3, "type": "Short-Flooring", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 4, "type": "Staircase", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 5, "type": "Bottom-Screw", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 6, "type": "Diagonals", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 7, "type": "Beam1", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 8, "type": "Beam2", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 9, "type": "Flooring", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 10, "type": "Flooring", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 11, "type": "Spire", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } }, { "id": 12, "type": "Railing", "batteryLevel": 100, "location": { "longitude": null, "latitude": null, "address": null } } ]`
)
.
Expect
(
t
)
.
...
...
@@ -29,8 +34,11 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
//Gets all Scaffolding parts
t
.
Run
(
"Get all Scaffolding parts"
,
func
(
t
*
testing
.
T
)
{
r
.
HandleFunc
(
"/stillastracking/v1/api/unit/"
,
endpoints
.
ScaffoldingRequest
)
ts
:=
httptest
.
NewServer
(
r
)
defer
ts
.
Close
()
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Get
(
"/stillastracking/v1/api/unit/"
)
.
Expect
(
t
)
.
Body
(
"{
\"
batteryLevel
\"
:100,
\"
id
\"
:7,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Beam1
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:8,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Beam2
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:5,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Bottom-Screw
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:6,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Diagonals
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:10,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Flooring
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:2,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Flooring
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:9,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Flooring
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:12,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Railing
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:3,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Short-Flooring
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:1,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Spire
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:11,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Spire
\"
}
\n
{
\"
batteryLevel
\"
:100,
\"
id
\"
:4,
\"
location
\"
:{
\"
address
\"
:null,
\"
latitude
\"
:null,
\"
longitude
\"
:null},
\"
type
\"
:
\"
Staircase
\"
}
\n
"
)
.
...
...
@@ -40,8 +48,11 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
//Gets all Scaffolding parts by Flooring
t
.
Run
(
"Get Scaffolding by type"
,
func
(
t
*
testing
.
T
)
{
r
.
HandleFunc
(
"/stillastracking/v1/api/unit"
,
endpoints
.
ScaffoldingRequest
)
.
Queries
()
ts
:=
httptest
.
NewServer
(
r
)
defer
ts
.
Close
()
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Get
(
"/stillastracking/v1/api/unit"
)
.
Query
(
"type"
,
"Flooring"
)
.
Expect
(
t
)
.
...
...
@@ -50,7 +61,7 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
End
()
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Get
(
"/stillastracking/v1/api/unit"
)
.
Query
(
"type"
,
"Beam1"
)
.
Expect
(
t
)
.
...
...
@@ -59,7 +70,7 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
End
()
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Get
(
"/stillastracking/v1/api/unit"
)
.
Query
(
"type"
,
"Staircase"
)
.
Expect
(
t
)
.
...
...
@@ -71,7 +82,7 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
//Gets a specific scaffolding part
t
.
Run
(
"Get Individual Scaffolding part"
,
func
(
t
*
testing
.
T
)
{
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Get
(
"/stillastracking/v1/api/unit"
)
.
Query
(
"type"
,
"Flooring"
)
.
Query
(
"id"
,
"9"
)
.
...
...
@@ -83,7 +94,7 @@ func Test_ScaffoldingAPITEST(t *testing.T) {
t
.
Run
(
"Delete all scaffolding parts"
,
func
(
t
*
testing
.
T
)
{
apitest
.
New
()
.
HandlerFunc
(
handler
)
.
HandlerFunc
(
endpoints
.
ScaffoldingRequest
)
.
Delete
(
"/stillastracking/v1/api/unit/"
)
.
Body
(
"[ {
\"
id
\"
: 7,
\"
type
\"
:
\"
Beam1
\"
}, {
\"
id
\"
: 8,
\"
type
\"
:
\"
Beam2
\"
}, {
\"
id
\"
: 5,
\"
type
\"
:
\"
Bottom-Screw
\"
}, {
\"
id
\"
: 6,
\"
type
\"
:
\"
Diagonals
\"
}, {
\"
id
\"
: 10,
\"
type
\"
:
\"
Flooring
\"
}, {
\"
id
\"
: 2,
\"
type
\"
:
\"
Flooring
\"
}, {
\"
id
\"
: 9,
\"
type
\"
:
\"
Flooring
\"
}, {
\"
id
\"
: 12,
\"
type
\"
:
\"
Railing
\"
}, {
\"
id
\"
: 3,
\"
type
\"
:
\"
Short-Flooring
\"
}, {
\"
id
\"
: 1,
\"
type
\"
:
\"
Spire
\"
}, {
\"
id
\"
: 11,
\"
type
\"
:
\"
Spire
\"
}, {
\"
id
\"
: 4,
\"
type
\"
:
\"
Staircase
\"
} ]"
)
.
Expect
(
t
)
.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment