Skip to content

Commit

Permalink
change form to json
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosRoGuerra committed Aug 3, 2021
1 parent 792f0ee commit 24d08e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
10 changes: 5 additions & 5 deletions tsuru/client/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,7 @@ func (s *S) TestAppRestart(c *check.C) {
CondFunc: func(req *http.Request) bool {
called = true
var restartResult map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&restartResult)
err = json.NewDecoder(req.Body).Decode(&restartResult)
c.Assert(err, check.IsNil)
c.Assert(restartResult, check.DeepEquals, map[string]interface{}{
"process": "web",
Expand Down Expand Up @@ -2766,7 +2766,7 @@ func (s *S) TestAppStart(c *check.C) {
CondFunc: func(req *http.Request) bool {
called = true
var startResult map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&startResult)
err = json.NewDecoder(req.Body).Decode(&startResult)
c.Assert(err, check.IsNil)
c.Assert(startResult, check.DeepEquals, map[string]interface{}{
"process": "worker",
Expand Down Expand Up @@ -2836,7 +2836,7 @@ func (s *S) TestAppStop(c *check.C) {
CondFunc: func(req *http.Request) bool {
called = true
var stopResult map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&stopResult)
err = json.NewDecoder(req.Body).Decode(&stopResult)
c.Assert(err, check.IsNil)
c.Assert(stopResult, check.DeepEquals, map[string]interface{}{
"process": "worker",
Expand Down Expand Up @@ -2874,7 +2874,7 @@ func (s *S) TestUnitAdd(c *check.C) {
CondFunc: func(req *http.Request) bool {
called = true
var result map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&result)
err = json.NewDecoder(req.Body).Decode(&result)
c.Assert(err, check.IsNil)
c.Assert(result, check.DeepEquals, map[string]interface{}{
"units": "3",
Expand Down Expand Up @@ -2909,7 +2909,7 @@ func (s *S) TestUnitAddWithVersion(c *check.C) {
CondFunc: func(req *http.Request) bool {
called = true
var result map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&result)
err = json.NewDecoder(req.Body).Decode(&result)
c.Assert(err, check.IsNil)
c.Assert(result, check.DeepEquals, map[string]interface{}{
"units": "3",
Expand Down
21 changes: 4 additions & 17 deletions tsuru/client/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package client
import (
"bytes"
"encoding/json"
"io/ioutil"
"net/http"
"strings"

Expand Down Expand Up @@ -148,7 +147,7 @@ func (s *S) TestEnvSetRun(c *check.C) {
Transport: cmdtest.Transport{Message: string(result), Status: http.StatusOK},
CondFunc: func(req *http.Request) bool {
var envResult map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&envResult)
err = json.NewDecoder(req.Body).Decode(&envResult)
c.Assert(err, check.IsNil)
c.Assert(envResult, check.DeepEquals, map[string]interface{}{"envs": []interface{}{map[string]interface{}{"name": "DATABASE_HOST",
"value": "somehost"}}})
Expand Down Expand Up @@ -208,11 +207,8 @@ variable 2`},
{Name: "LINE1", Value: "multiline\nvariable 1", Alias: "", Private: private},
{Name: "LINE2", Value: "multiline\nvariable 2", Alias: "", Private: private},
}
err = req.ParseForm()
var e tsuru.EnvSetData
data, err := ioutil.ReadAll(req.Body)
c.Assert(err, check.IsNil)
err = json.Unmarshal(data, &e)
err = json.NewDecoder(req.Body).Decode(&e)
c.Assert(err, check.IsNil)
c.Assert(e.Envs, check.DeepEquals, want)
private = !e.Private
Expand Down Expand Up @@ -263,13 +259,8 @@ func (s *S) TestEnvSetValues(c *check.C) {
{Name: "BASE64_STRING", Value: "t5urur0ck5==", Alias: "", Private: private},
{Name: "SOME_PASSWORD", Value: "js87$%32??", Alias: "", Private: private},
}
err = req.ParseForm()
c.Assert(err, check.IsNil)
var e tsuru.EnvSetData
c.Assert(err, check.IsNil)
data, err := ioutil.ReadAll(req.Body)
c.Assert(err, check.IsNil)
err = json.Unmarshal(data, &e)
err = json.NewDecoder(req.Body).Decode(&e)
c.Assert(err, check.IsNil)
c.Assert(e.Envs, check.DeepEquals, want)
private = !e.Private
Expand Down Expand Up @@ -319,12 +310,8 @@ func (s *S) TestEnvSetValuesAndPrivateAndNoRestart(c *check.C) {
{Name: "VALUE_WITH_EQUAL_SIGN", Value: "http://wholikesquerystrings.me/?tsuru=awesome", Private: private},
{Name: "BASE64_STRING", Value: "t5urur0ck5==", Alias: "", Private: private},
}
err = req.ParseForm()
c.Assert(err, check.IsNil)
var e tsuru.EnvSetData
data, err := ioutil.ReadAll(req.Body)
c.Assert(err, check.IsNil)
err = json.Unmarshal(data, &e)
err = json.NewDecoder(req.Body).Decode(&e)
c.Assert(err, check.IsNil)
c.Assert(e.Envs, check.DeepEquals, want)
private = e.Private
Expand Down
2 changes: 1 addition & 1 deletion tsuru/client/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (s *S) TestServiceInstanceBind(c *check.C) {
method := req.Method == "PUT"
path := strings.HasSuffix(req.URL.Path, "/services/mysql/instances/my-mysql/g1")
var bindResult map[string]interface{}
err := json.NewDecoder(req.Body).Decode(&bindResult)
err = json.NewDecoder(req.Body).Decode(&bindResult)
c.Assert(err, check.IsNil)
c.Assert(bindResult, check.DeepEquals, map[string]interface{}{
"noRestart": true,
Expand Down

0 comments on commit 24d08e5

Please sign in to comment.