File: logs_index_lists_test.go

package info (click to toggle)
golang-github-zorkian-go-datadog-api 2.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,612 kB
  • sloc: makefile: 28; sh: 13
file content (31 lines) | stat: -rw-r--r-- 621 bytes parent folder | download
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
package datadog

import (
	"github.com/stretchr/testify/assert"
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"testing"
)

func TestLogsIndexListGet(t *testing.T) {
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		response, err := ioutil.ReadFile("./tests/fixtures/logs/indexlist_response.json")
		assert.Nil(t, err)
		w.Write(response)
	}))

	defer ts.Close()

	client := Client{
		baseUrl:    ts.URL,
		HttpClient: http.DefaultClient,
	}

	indexList, err := client.GetLogsIndexList()

	assert.Nil(t, err)

	assert.Equal(t, []string{"main", "minor"}, indexList.IndexNames)

}