Skip to content

Commit

Permalink
add test /hello for route
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanLovesCoffee committed Jan 10, 2024
1 parent 5d27996 commit 70cbf83
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/serverless/daemon/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@ func TestTraceContext(t *testing.T) {
}
}

func TestHello(t *testing.T) {
assert := assert.New(t)

port := testutil.FreeTCPPort(t)
d := StartDaemon(fmt.Sprintf("127.0.0.1:%d", port))
time.Sleep(100 * time.Millisecond)
defer d.Stop()
d.InvocationProcessor = &invocationlifecycle.LifecycleProcessor{
ExtraTags: d.ExtraTags,
Demux: nil,
ProcessTrace: nil,
DetectLambdaLibrary: d.IsLambdaLibraryDetected,
}
client := &http.Client{}
body := bytes.NewBuffer([]byte(`{}`))
request, err := http.NewRequest(http.MethodPost, fmt.Sprintf("http://127.0.0.1:%d/lambda/hello", port), body)
assert.Nil(err)
assert.False(d.IsLambdaLibraryDetected())
response, err := client.Do(request)
assert.Nil(err)
response.Body.Close()
assert.True(d.IsLambdaLibraryDetected())
}

func TestStartEndInvocationSpanParenting(t *testing.T) {
port := testutil.FreeTCPPort(t)
d := StartDaemon(fmt.Sprintf("127.0.0.1:%d", port))
Expand Down

0 comments on commit 70cbf83

Please sign in to comment.