(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestMain(t *testing.T) { |
| 16 | d := time.Now().Add(50 * time.Millisecond) |
| 17 | os.Setenv("AWS_LAMBDA_FUNCTION_NAME","blank-go") |
| 18 | ctx, _ := context.WithDeadline(context.Background(), d) |
| 19 | ctx = lambdacontext.NewContext(ctx, &lambdacontext.LambdaContext{ |
| 20 | AwsRequestID: "495b12a8-xmpl-4eca-8168-160484189f99", |
| 21 | InvokedFunctionArn: "arn:aws:lambda:us-east-2:123456789012:function:blank-go", |
| 22 | }) |
| 23 | inputJson := ReadJSONFromFile(t, "../event.json") |
| 24 | var event events.SQSEvent |
| 25 | err := json.Unmarshal(inputJson, &event) |
| 26 | if err != nil { |
| 27 | t.Errorf("could not unmarshal event. details: %v", err) |
| 28 | } |
| 29 | //var inputEvent SQSEvent |
| 30 | result, err := handleRequest(ctx, event) |
| 31 | if err != nil { |
| 32 | t.Log(err) |
| 33 | } |
| 34 | t.Log(result) |
| 35 | if !strings.Contains(result, "FunctionCount") { |
| 36 | t.Errorf("Output does not contain FunctionCount.") |
| 37 | } |
| 38 | } |
| 39 | func ReadJSONFromFile(t *testing.T, inputFile string) []byte { |
| 40 | inputJSON, err := ioutil.ReadFile(inputFile) |
| 41 | if err != nil { |
nothing calls this directly
no test coverage detected