MCPcopy
hub / github.com/tsuru/tsuru / TestServiceCreateWithJSONEncoding

Method TestServiceCreateWithJSONEncoding

api/service_test.go:344–367  ·  view source on GitHub ↗
(c *check.C)

Source from the content-addressed store, hash-verified

342}
343
344func (s *ProvisionSuite) TestServiceCreateWithJSONEncoding(c *check.C) {
345 v := url.Values{}
346 v.Set("id", "json-service")
347 v.Set("username", "user")
348 v.Set("password", "password")
349 v.Set("endpoint", "http://json.service.example.com")
350 v.Set("encoding", "json")
351 recorder, request := s.makeRequest(http.MethodPost, "/services", v.Encode(), c)
352 request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
353 s.testServer.ServeHTTP(recorder, request)
354 c.Assert(recorder.Code, check.Equals, http.StatusCreated)
355 query := mongoBSON.M{"_id": "json-service"}
356 var rService service.Service
357
358 servicesCollection, err := storagev2.ServicesCollection()
359 c.Assert(err, check.IsNil)
360
361 err = servicesCollection.FindOne(context.TODO(), query).Decode(&rService)
362 c.Assert(err, check.IsNil)
363 c.Assert(rService.Endpoint["production"], check.Equals, "http://json.service.example.com")
364 c.Assert(rService.Username, check.Equals, "user")
365 c.Assert(rService.Password, check.Equals, "password")
366 c.Assert(rService.Encoding, check.Equals, service.ServiceEncodingJSON)
367}
368
369func (s *ProvisionSuite) TestServiceCreateWithInvalidEncoding(c *check.C) {
370 v := url.Values{}

Callers

nothing calls this directly

Calls 5

makeRequestMethod · 0.95
ServicesCollectionFunction · 0.92
SetMethod · 0.65
EncodeMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected