forked from nerdswords/yet-another-cloudwatch-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws_cloudwatch_test.go
43 lines (36 loc) · 903 Bytes
/
aws_cloudwatch_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
35
36
37
38
39
40
41
42
43
package main
import (
"strings"
"testing"
"github.com/aws/aws-sdk-go/service/cloudwatch"
)
func TestDimensionsToCliString(t *testing.T) {
// Setup Test
// Arrange
dimensions := []*cloudwatch.Dimension{}
expected := ""
// Act
actual := dimensionsToCliString(dimensions)
// Assert
if actual != expected {
t.Fatalf("\nexpected: %q\nactual: %q", expected, actual)
}
}
func TestGetNamespace(t *testing.T) {
for _, jobType := range supportedServices {
ns, err := getNamespace(jobType)
if err != nil {
t.Fatalf("jobType %s shouldn't have returned error", jobType)
}
if ns == "" {
t.Fatalf("jobType %s seems to have empty namespace", jobType)
}
}
ns, err := getNamespace("foobar")
if !strings.Contains(err.Error(), "foobar") {
t.Fatalf("jobType foobar should have returned error")
}
if ns != "" {
t.Fatalf("jobType foobar should have returned empty string")
}
}