Debian Codegraph @

plugin/someteam.example.com/v1/printpluginenv/PrintPluginEnv_test.go

raw
1 // Copyright 2019 The Kubernetes Authors.
2 // SPDX-License-Identifier: Apache-2.0
3
4 package main_test
5
6 import (
7 "strings"
8 "testing"
9
10 kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
11 )
12
13 func shouldContain(t *testing.T, s []byte, x string) {
14 if !strings.Contains(string(s), x) {
15 t.Fatalf("unable to find %s", x)
16 }
17 }
18
19 func TestPrintPluginEnvPlugin(t *testing.T) {
20 th := kusttest_test.MakeEnhancedHarness(t).
21 PrepExecPlugin("someteam.example.com", "v1", "PrintPluginEnv")
22 // Just to be clear.
23 th.ResetLoaderRoot("/theAppRoot")
24 defer th.Reset()
25
26 m := th.LoadAndRunGenerator(`
27 apiVersion: someteam.example.com/v1
28 kind: PrintPluginEnv
29 metadata:
30 name: whatever
31 `)
32 a, err := m.AsYaml()
33 if err != nil {
34 t.Error(err)
35 }
36 shouldContain(t, a, "kustomize_plugin_config_root: /theAppRoot")
37 shouldContain(t, a, "plugin/someteam.example.com/v1/printpluginenv")
38 }