Commit graph

18 commits

Author SHA1 Message Date
Sonja Happ
f339c0d135 - revise testing of file endpoints
- revise documentation for swaggo
- clean up testdata
- delete serializers and responses files
- revise file endpoint implementations
2019-09-06 17:04:40 +02:00
Sonja Happ
7544c863de - revise testing of signal endpoints
- revise documentation for swaggo
- clean up testdata, serializers and responses
- add validators for signal endpoints
- revise signal endpoint implementations
2019-09-06 16:01:59 +02:00
Sonja Happ
e3651e34f0 - revise testing of widget enpoints
- add validators for widgets
- revise implementation of widget endpoints
- clean up testdata, serializers and response
- improve documentation for swaggo
2019-09-06 15:10:25 +02:00
Sonja Happ
dab027eef6 - revise testing of dashboard enpoints
- clean up testdata, serializers and responses
- add validators for dashboards
- revise documentation of dashboard endpoints for swaggo
- revise endpoint implementations
2019-09-06 14:07:36 +02:00
Sonja Happ
4914af6c47 - revise simulation model testing
- add validators for simulation model endpoints
- revise endpoint implementations and fix responses of simulation models
- clean up testdata, serializers and responses for simulation models
- change default values of output length and input length of signal mappings to 0
2019-09-05 16:17:00 +02:00
Sonja Happ
a55d039ee7 - revise testing of simulators
- add validators for simulators
- clean up testdata, serializers and responses
- update documentation for swaggo
2019-09-05 12:23:44 +02:00
Sonja Happ
16b3499126 get rid of Request struct as is caused more trouble than good 2019-09-05 09:11:56 +02:00
Sonja Happ
2772bde5ee - Modify scenario testing
- Add scenario validators
- Clean up responses and serializes with respect to scenario
- Fix error handling and responses of scenario endpoints
2019-09-04 16:31:20 +02:00
Sonja Happ
768a108627 add credentials for UserA and UserB 2019-09-04 09:58:08 +02:00
Sonja Happ
36dfda1ac0 do not change global test data in database tests, add data in each test function and do not use populateDummyDB function in DB testing 2019-09-03 15:12:18 +02:00
smavros
59a37bf601 Removes Credentials type from common/models.go:
Every test will fail except from the user's package since it is the
    only one using the new Request type.
2019-08-13 19:21:39 +02:00
smavros
76658c3ed4 Bug fix (read that commit message!):
The problem started with an internal error in the database (HTTP
    code 500, pq: duplicate key value) while trying to POST at /api/user
    with body {"user":{newUserObject}} to the backend, that already had
    three users User0 (Admin), UserA and UserB. Every test was
    succeeding.

    Eventually, the source of the problem was the initialization of the
    field `ID` (primary key) of the embedded struct `Model` in model
    `User`. When the `User` global variables User0, UserA and UserB
    were created in `common/testdata.go` the `Model.ID` field was set
    manually to the values 1, 2 and 3 respectively. This ofc was
    unnecessary but those variables were used for comparison with the
    relevant responses.

    When gorm (or postgres, not entirely sure) have a new variable of a
    model type, it will check if its primary key is zero (which means is
    uninitialized) and will set it to the last used value +1. That means
    that the new user that we were trying to insert in the DB got the
    primary key value 1. This value was already in use by the User0 so
    the DB refused to add the new user since there was a duplicate
    primary key value. That's why we were getting an postgre's error and
    HTTP 500.

    Hence to fix the bug this commit:

    - Removes `User.ID` initialization from `common/testdata.go`

    - Omits the `User.ID` from the json marshaler by setting the struct
    json tag to `json:"-"`. This is done because the request body is
    compared to the response *after* is serialized by a call to
    json.Marshal(). Since the `User.ID` is always uninitialized (value
    0) the jsondiff.Compare() will always return a "NoMatch".

    - Includes check for return of "SupersetMatch" in
    NewTestEndpoint()'s jsondiff.Compare() call. Since the `User.ID` is
    not serialized the json representation of the request will not
    include an "id" key. On the contrary, the response *has* an "id" key
    so it will always going to be a superset json object of the
    serialized request.

    - Modifies the validator's data struct to match the form of the
    request ({"modelKey":{requestBody}}) by adding an intermediate
    struct with the proper tag `json:"user"`.
2019-08-13 01:45:24 +02:00
smavros
4a1de4a471 Improves testdata. Removes User*_response. 2019-08-11 18:00:15 +02:00
smavros
cf69e59a5f Modifies testdata setup:
- Decorates User model with json tags for marshaling.
    - Introduces Model type same as gorm.Model with additional json tags
    for marshaling.
    - Modifies ResponseMsgUsers type.
    - Modifies the testdata for the users by including initializer for
    the Mode.ID field.
    - The scenario test fails for those changes
2019-07-30 20:31:59 +02:00
Sonja Happ
92eb455e5a revise widget testing 2019-07-25 13:25:46 +02:00
Sonja Happ
65f7a9b493 revise file testing 2019-07-25 12:44:52 +02:00
Sonja Happ
a06d90d085 revise dashboard testing 2019-07-25 11:38:28 +02:00
Sonja Happ
d79fb53cb2 - create all test data in one file
- revise testing functions (WORK IN PROGRESS)
2019-07-25 11:22:39 +02:00