github.com/newrelic/go-agent@v3.26.0+incompatible/_integrations/nrlambda/config_test.go (about)

     1  // Copyright 2020 New Relic Corporation. All rights reserved.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package nrlambda
     5  
     6  import (
     7  	"testing"
     8  	"time"
     9  )
    10  
    11  func TestNewConfig(t *testing.T) {
    12  	cfg := newConfigInternal(func(key string) string {
    13  		switch key {
    14  		case "NEW_RELIC_ACCOUNT_ID":
    15  			return "the-account-id"
    16  		case "NEW_RELIC_TRUSTED_ACCOUNT_KEY":
    17  			return "the-trust-key"
    18  		case "NEW_RELIC_PRIMARY_APPLICATION_ID":
    19  			return "the-app-id"
    20  		case "NEW_RELIC_APDEX_T":
    21  			return "2"
    22  		default:
    23  			return ""
    24  		}
    25  	})
    26  	if !cfg.ServerlessMode.Enabled {
    27  		t.Error(cfg.ServerlessMode.Enabled)
    28  	}
    29  	if cfg.ServerlessMode.AccountID != "the-account-id" {
    30  		t.Error(cfg.ServerlessMode.AccountID)
    31  	}
    32  	if cfg.ServerlessMode.TrustedAccountKey != "the-trust-key" {
    33  		t.Error(cfg.ServerlessMode.TrustedAccountKey)
    34  	}
    35  	if cfg.ServerlessMode.PrimaryAppID != "the-app-id" {
    36  		t.Error(cfg.ServerlessMode.PrimaryAppID)
    37  	}
    38  	if cfg.ServerlessMode.ApdexThreshold != 2*time.Second {
    39  		t.Error(cfg.ServerlessMode.ApdexThreshold)
    40  	}
    41  }