-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathruntimelogs_stub_test.go
More file actions
37 lines (28 loc) · 1.25 KB
/
runtimelogs_stub_test.go
File metadata and controls
37 lines (28 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package handler
import (
"bytes"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSuccessfulRuntimeLogsAPIStub202Response(t *testing.T) {
handler := NewRuntimeLogsAPIStubHandler()
requestBody := []byte(`foobar`)
request := httptest.NewRequest("PUT", "/logs", bytes.NewBuffer(requestBody))
responseRecorder := httptest.NewRecorder()
handler.ServeHTTP(responseRecorder, request)
assert.Equal(t, http.StatusAccepted, responseRecorder.Code)
assert.JSONEq(t, `{"errorMessage":"Logs API is not supported","errorType":"Logs.NotSupported"}`, responseRecorder.Body.String())
}
func TestSuccessfulRuntimeTelemetryAPIStub202Response(t *testing.T) {
handler := NewRuntimeTelemetryAPIStubHandler()
requestBody := []byte(`{"name": "foobar"}`)
request := httptest.NewRequest("PUT", "/telemetry", bytes.NewBuffer(requestBody))
responseRecorder := httptest.NewRecorder()
handler.ServeHTTP(responseRecorder, request)
assert.Equal(t, http.StatusAccepted, responseRecorder.Code)
assert.JSONEq(t, `{"errorMessage":"Telemetry API is not supported","errorType":"Telemetry.NotSupported"}`, responseRecorder.Body.String())
}