buildHTTPDoc creates a NetworkTrafficDoc with an HTTP spec for testing.
()
| 21 | |
| 22 | // buildHTTPDoc creates a NetworkTrafficDoc with an HTTP spec for testing. |
| 23 | func buildHTTPDoc() *NetworkTrafficDoc { |
| 24 | doc := &NetworkTrafficDoc{ |
| 25 | Version: models.V1Beta1, |
| 26 | Kind: models.HTTP, |
| 27 | Name: "test-1", |
| 28 | Curl: "curl http://localhost:8080/api", |
| 29 | } |
| 30 | spec := models.HTTPSchema{ |
| 31 | Request: models.HTTPReq{ |
| 32 | Method: "GET", |
| 33 | URL: "http://localhost:8080/api", |
| 34 | Header: map[string]string{"Content-Type": "application/json"}, |
| 35 | Body: `{"key":"value"}`, |
| 36 | }, |
| 37 | Response: models.HTTPResp{ |
| 38 | StatusCode: 200, |
| 39 | StatusMessage: "OK", |
| 40 | Header: map[string]string{"Content-Type": "application/json"}, |
| 41 | Body: `{"result":"ok"}`, |
| 42 | }, |
| 43 | Created: 1700000000, |
| 44 | } |
| 45 | if err := doc.Spec.Encode(spec); err != nil { |
| 46 | panic(err) |
| 47 | } |
| 48 | return doc |
| 49 | } |
| 50 | |
| 51 | func TestParseFormat(t *testing.T) { |
| 52 | tests := []struct { |
no outgoing calls
no test coverage detected