forked from wavefrontHQ/wavefront-lambda-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwflambda_test.go
34 lines (31 loc) · 1.06 KB
/
wflambda_test.go
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
package wflambda
import (
"os"
"testing"
)
func TestGetStandardLambdaMetricName(t *testing.T) {
actualName := getStandardLambdaMetricName("customMetric", true)
expectedName := "aws.lambda.wf.customMetric_event"
if actualName != expectedName {
t.Error("Metric names don't match ", expectedName, actualName)
}
actualName = getStandardLambdaMetricName("customMetrics", false)
expectedName = "aws.lambda.wf.customMetrics"
if actualName != expectedName {
t.Error("Metric names don't match ", expectedName, actualName)
}
}
func TestGetAndValidateLambdaEnvironment(t *testing.T) {
os.Setenv("WAVEFRONT_URL", "https://demo.wavefront.com")
os.Setenv("WAVEFRONT_API_TOKEN", "demo-api-token")
os.Setenv("REPORT_STANDARD_METRICS", "False")
expected := getAndValidateLambdaEnvironment()
if expected != false {
t.Error("Validate environmental variables failed ", expected, "False")
}
os.Setenv("REPORT_STANDARD_METRICS", "true")
expected = getAndValidateLambdaEnvironment()
if expected != true {
t.Error("Validate environmental variables failed ", expected, "true")
}
}