(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestStatisticsInfo(t *testing.T) { |
| 32 | cmid := "commit-xxx" |
| 33 | funcName := "test" |
| 34 | reqid := id.GetRequestID() |
| 35 | now := time.Now().UnixNano() |
| 36 | ver := "1" |
| 37 | timeout := int64(3) |
| 38 | reqinfo := RequestInfo{ |
| 39 | RequestID: reqid, |
| 40 | InvokeStartTimeNS: now, |
| 41 | InvokeStartTimeMS: now / int64(time.Millisecond), |
| 42 | SyncChannel: make(chan struct{}, 1), |
| 43 | TimeoutChannel: make(chan struct{}, 1), |
| 44 | Status: StatusSuccess, |
| 45 | Input: &InvocationInput{ |
| 46 | RequestID: reqid, |
| 47 | Configuration: &api.FunctionConfiguration{ |
| 48 | CommitID: &cmid, |
| 49 | FunctionConfiguration: lambda.FunctionConfiguration{ |
| 50 | Version: &ver, |
| 51 | Timeout: &timeout, |
| 52 | FunctionName: &funcName, |
| 53 | }, |
| 54 | }, |
| 55 | User: &api.User{ |
| 56 | ID: "xxx", |
| 57 | }, |
| 58 | WithStreamMode: true, |
| 59 | Request: &api.InvokeProxyRequest{ |
| 60 | Headers: make(map[string]string, 0), |
| 61 | Body: []byte("{}"), |
| 62 | }, |
| 63 | Response: api.NewInvokeProxyResponse(), |
| 64 | EnableMetrics: false, |
| 65 | Logger: logs.NewLogger().WithField("request_id", reqid), |
| 66 | }, |
| 67 | Output: &InvocationOutput{Output: &InvocationResponse{}, Statistic: &InvocationStatistic{}}, |
| 68 | } |
| 69 | info := statisticsInfo(&reqinfo) |
| 70 | if info == nil { |
| 71 | t.Error("statistics info should not be nil") |
| 72 | return |
| 73 | } |
| 74 | if err := info.Decode(info.Encode()); err != nil { |
| 75 | t.Errorf("encode/decode statistic info failed: %s", err) |
| 76 | } |
| 77 | } |
nothing calls this directly
no test coverage detected