File: config_test.go

package info (click to toggle)
golang-github-newrelic-go-agent 3.15.2-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 8,356 kB
  • sloc: sh: 65; makefile: 6
file content (41 lines) | stat: -rw-r--r-- 1,010 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
35
36
37
38
39
40
41
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package nrlambda

import (
	"testing"
	"time"
)

func TestNewConfig(t *testing.T) {
	cfg := newConfigInternal(func(key string) string {
		switch key {
		case "NEW_RELIC_ACCOUNT_ID":
			return "the-account-id"
		case "NEW_RELIC_TRUSTED_ACCOUNT_KEY":
			return "the-trust-key"
		case "NEW_RELIC_PRIMARY_APPLICATION_ID":
			return "the-app-id"
		case "NEW_RELIC_APDEX_T":
			return "2"
		default:
			return ""
		}
	})
	if !cfg.ServerlessMode.Enabled {
		t.Error(cfg.ServerlessMode.Enabled)
	}
	if cfg.ServerlessMode.AccountID != "the-account-id" {
		t.Error(cfg.ServerlessMode.AccountID)
	}
	if cfg.ServerlessMode.TrustedAccountKey != "the-trust-key" {
		t.Error(cfg.ServerlessMode.TrustedAccountKey)
	}
	if cfg.ServerlessMode.PrimaryAppID != "the-app-id" {
		t.Error(cfg.ServerlessMode.PrimaryAppID)
	}
	if cfg.ServerlessMode.ApdexThreshold != 2*time.Second {
		t.Error(cfg.ServerlessMode.ApdexThreshold)
	}
}