Files
kustomize/plugin/someteam.example.com/v1/someservicegenerator/SomeServiceGenerator_test.go
2019-07-10 20:43:50 -07:00

45 lines
826 B
Go

// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package main_test
import (
"testing"
"sigs.k8s.io/kustomize/v3/pkg/kusttest"
plugins_test "sigs.k8s.io/kustomize/v3/pkg/plugins/test"
)
func TestSomeServiceGeneratorPlugin(t *testing.T) {
tc := plugins_test.NewEnvForTest(t).Set()
defer tc.Reset()
tc.BuildGoPlugin(
"someteam.example.com", "v1", "SomeServiceGenerator")
th := kusttest_test.NewKustTestPluginHarness(t, "/app")
m := th.LoadAndRunGenerator(`
apiVersion: someteam.example.com/v1
kind: SomeServiceGenerator
metadata:
name: my-service
namespace: test
port: "12345"
`)
th.AssertActualEqualsExpected(m, `
apiVersion: v1
kind: Service
metadata:
labels:
app: dev
name: my-service
namespace: test
spec:
ports:
- port: 12345
selector:
app: dev
`)
}