Commit Graph

619 Commits

Author SHA1 Message Date
Roberto Abdelkader Martínez Pérez
31f6015110 Increase legibility of gorillize function 2019-10-09 08:39:12 +02:00
Roberto Abdelkader Martínez Pérez
f656f9f3b0 Change function gorillize signature slightly 2019-10-08 21:09:48 +02:00
pancho horrillo
2cd96d5a4b Add the controversial gorillize()
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 19:39:44 +02:00
pancho horrillo
037347dbe3 Augment safeRouteList.Append() to return a model.Route with index
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 17:53:15 +02:00
pancho horrillo
e0dd6f5dd5 Refactor internal/server/user package structure
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 17:22:09 +02:00
Héctor Hurtado
6df4369358 Added test for checking Index 2019-10-08 16:18:51 +02:00
Héctor Hurtado
4a258e74ce Added Index fient to the Route model 2019-10-08 15:40:43 +02:00
pancho horrillo
2eb32610a0 Exclude test from race condition verification
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 15:34:42 +02:00
pancho horrillo
9ad61249b3 Fix linter warning
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-08 15:33:32 +02:00
Héctor Hurtado
a4b1a5504b Merge branch 'master' of ssh://github.com/BBVA/kapow 2019-10-08 15:15:02 +02:00
Héctor Hurtado
198584f517 First green in control server 2019-10-08 15:14:50 +02:00
pancho horrillo
3b405bd9f6 Add ServeHTTP() method to swappableMux struct
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-08 15:06:08 +02:00
Héctor Hurtado
3fa2357f71 First failing test in control package 2019-10-08 12:35:05 +02:00
Héctor Hurtado
8fe46d1c6b Merge branch 'master' of ssh://github.com/BBVA/kapow 2019-10-08 12:03:13 +02:00
Héctor Hurtado
fe7d962581 Reworking in module definition 2019-10-08 12:02:46 +02:00
Roberto Abdelkader Martínez Pérez
0eb802ea78 Change to latest linter version 2019-10-08 09:48:04 +02:00
Héctor Hurtado
73e05afee3 Merge branch 'master' of ssh://github.com/BBVA/kapow 2019-10-08 09:42:03 +02:00
Héctor Hurtado
98faa6f155 Merge branch 'feature_server_launcher' 2019-10-08 09:41:19 +02:00
Héctor Hurtado
bb0a283813 Prepare to merge master 2019-10-08 09:40:51 +02:00
Roberto Abdelkader Martínez Pérez
f346392eea Add linter to makefile and to circleci 2019-10-08 09:26:57 +02:00
Héctor Hurtado
02f0410685 Merge branch 'feature_control_server' 2019-10-08 09:21:27 +02:00
Héctor Hurtado
e32116abad Rewrite 2019-10-08 09:20:58 +02:00
Roberto Abdelkader Martínez Pérez
0348df1df5 Prevent linter from reporting a deprecation warning in a test 2019-10-08 09:09:47 +02:00
Roberto Abdelkader Martínez Pérez
22f03eb67f Move swappableMux and its methods to its own module 2019-10-08 09:01:40 +02:00
Héctor Hurtado
7fdef70e39 Moved to internal 2019-10-08 08:56:04 +02:00
Héctor Hurtado
56db1ce2ac Moved to internal 2019-10-08 08:54:07 +02:00
pancho horrillo
0cab49f082 Simplify handling of http.Client response
As per the doc¹:

  If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
  ...
  On error, any Response can be ignored. A non-nil Response with a non-nil error
  only occurs when CheckRedirect fails, and even then the returned Response.Body
  is already closed.

It is thus safe to defer res.Body.Close() as soon as err has been determined to
be nil.

Also, I've dispensed with the separate variable client, since it is not used
later.

¹: https://godoc.org/net/http#Client.Do
2019-10-08 05:42:33 +02:00
pancho horrillo
7ba54b32b3 Revert to using strings for simplicity
It is safe in this case.

* gock.BodyString(body string) coerces body into a []byte
* client.SetData() eventually resolves to a call to http.Client.Do(), which
handles the string gracefully as well.
2019-10-08 05:28:29 +02:00
pancho horrillo
10586bae95 Add internal/server/user/server{,_test}.go
Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2019-10-07 19:05:59 +02:00
Héctor Hurtado
9266f48c7e First test 2019-10-07 16:00:14 +02:00
Héctor Hurtado
81379c22e2 First non-working version of server package 2019-10-07 13:48:35 +02:00
Roberto Abdelkader Martínez Pérez
10da324a57 Perform a race test after the tests 2019-10-07 08:55:34 +02:00
Roberto Abdelkader Martínez Pérez
47bd2be882 Some fixes suggested by golangci-lint 2019-10-07 08:53:48 +02:00
Roberto Abdelkader Martínez Pérez
7e54c26cb8 Don't test for false boolean value 2019-10-07 07:34:57 +02:00
Roberto Abdelkader Martínez Pérez
17020ad134 Some tests for Get/Post/Put/Delete utility functions 2019-10-07 07:33:35 +02:00
pancho horrillo
0b056f6cf0 internal/client/{get,set}_test.go: send io.Writer() based on []byte
* internal/client/get_test.go:
  - Revert changes when setting the Body of the mock (gock).
  - Revert over-eager line splitting.

* internal/client/set_test.go:
  - Use bytes.NewReader([]byte("200")) instead of strings.NewReader("200")

Thanks to @nilp0inter for the feedback!
2019-10-06 11:34:15 +02:00
pancho horrillo
f98784088d Normalize internal/client/*_test.go
* Adjust test style for easy reading, by using literals instead of vars
* Move comparison to the `bytes` domain, instead of `string`
* Simplify testing code by using bytes.Buffer directly
* More consistent naming of variables and dummies (HANDLE_{FOO,BAR,BAD})
* Consistent testing style of gock.IsDone()
* Stick to 80-column
2019-10-06 09:41:12 +02:00
Roberto Abdelkader Martínez Pérez
25409a2cee Exclude tests from race check 2019-10-05 12:28:01 +02:00
Roberto Abdelkader Martínez Pérez
382f056bbd Test for singleton handler map in package 2019-10-05 12:23:05 +02:00
Roberto Abdelkader Martínez Pérez
62ec810e6d Implemented user server state aka route list 2019-10-05 12:22:38 +02:00
Roberto Abdelkader Martínez Pérez
edb3f6fa1c More consistent naming 2019-10-05 11:44:37 +02:00
Roberto Abdelkader Martínez Pérez
60437ea9e5 Data server state aka handlers 2019-10-04 19:21:01 +02:00
Roberto Abdelkader Martínez Pérez
fb2f94997e Separate race detection from test phase to allow mutex tests 2019-10-04 19:20:32 +02:00
pancho horrillo
6154210b3f Update PoC and features with the 204 -> 404 update
Closes #33
2019-10-04 17:24:27 +02:00
Roberto Abdelkader Martínez Pérez
97b8c3fce4 Server data model 2019-10-04 16:28:19 +02:00
Héctor Hurtado
bbda43b193 Merge branch 'master' of ssh://github.com/BBVA/kapow 2019-10-04 14:33:00 +02:00
Héctor Hurtado
feaa836093 Connect set command. TODOs in route command 2019-10-04 14:32:39 +02:00
Roberto Abdelkader Martínez Pérez
4224984e1b Add spacing to comments 2019-10-04 14:18:42 +02:00
Roberto Abdelkader Martínez Pérez
bf88e6a78b Simplify test cases 2019-10-04 14:08:47 +02:00
Héctor Hurtado
6b34047d75 Added gock.IsDone() to route list and remove tests. Remove content type in route remove command. Removed disturbing data for texts. Remove unneeded test in set command. 2019-10-04 13:55:36 +02:00