contour: Add conversion test
This test adds a test case to verify if the newly added parameter
`envoy.metrics_scrape_interval` correctly converts and becomes a part of
`ServiceMonitor` config.
@@ -17,6 +17,7 @@ package contour
import (
"testing"
+ "github.com/kinvolk/lokomotive/pkg/components/internal/testutil"
"github.com/kinvolk/lokomotive/pkg/components/util"
)
@@ -90,3 +91,39 @@ component "contour" {
}
}
}
+
+func TestConversion(t *testing.T) {
+ testCases := []struct {
+ name string
+ inputConfig string
+ expectedManifestName string
+ expected string
+ jsonPath string
+ }{
+ {
+ name: "default ServiceMonitor",
+ inputConfig: `component "contour" {
+ enable_monitoring = true
+ envoy {
+ metrics_scrape_interval = "10s"
+ }
+ }`,
+ expectedManifestName: "contour/templates/service-monitor.yaml",
+ jsonPath: "{.spec.endpoints[0].interval}",
+ expected: "10s",
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+ t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+
+ component := newComponent()
+ m := testutil.RenderManifests(t, component, name, tc.inputConfig)
+ gotConfig := testutil.ConfigFromMap(t, m, tc.expectedManifestName)
+
+ testutil.MatchJSONPathStringValue(t, gotConfig, tc.jsonPath, tc.expected)
+ })
+ }
+}
