File: app_keys_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 (34 lines) | stat: -rw-r--r-- 729 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
32
33
34
/*
 * Datadog API for Go
 *
 * Please see the included LICENSE file for licensing information.
 *
 * Copyright 2019 by authors and contributors.
 */

package datadog_test

import (
	"encoding/json"
	"testing"

	"github.com/stretchr/testify/assert"
	dd "github.com/zorkian/go-datadog-api"
)

func TestAPPKeySerialization(t *testing.T) {

	raw := `
	{
		"owner": "john@example.com",
		"name": "myCoolKey",
		"hash": "31111111111111111111aaaaaaaaaaaaaaaaaaaa"
	}`

	var appkey dd.APPKey
	err := json.Unmarshal([]byte(raw), &appkey)
	assert.Equal(t, err, nil)
	assert.Equal(t, *appkey.Name, "myCoolKey")
	assert.Equal(t, *appkey.Owner, "john@example.com")
	assert.Equal(t, *appkey.Hash, "31111111111111111111aaaaaaaaaaaaaaaaaaaa")
}