MCPcopy
hub / github.com/argoproj/argo-workflows / TestExampleWorkflows

Function TestExampleWorkflows

test/e2e/examples_test.go:30–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28)
29
30func TestExampleWorkflows(t *testing.T) {
31 restConfig, err := kubeconfig.DefaultRestConfig()
32 if err != nil {
33 t.Fatal(err)
34 }
35 kubeClient, err := kubernetes.NewForConfig(restConfig)
36 if err != nil {
37 t.Fatal(err)
38 }
39 dyn := dynamic.NewForConfigOrDie(restConfig)
40
41 configController := config.NewController(fixtures.Namespace, common.ConfigMapName, kubeClient)
42 ctx := logging.TestContext(t.Context())
43 config, err := configController.Get(ctx)
44 if err != nil {
45 t.Fatal(err)
46 }
47 persistence := fixtures.NewPersistence(ctx, kubeClient, config)
48
49 clientset, err := kubernetes.NewForConfig(restConfig)
50 if err != nil {
51 t.Fatal(err)
52 }
53 sec, err := clientset.CoreV1().Secrets(fixtures.Namespace).Get(ctx, secrets.TokenName("argo-server"), metav1.GetOptions{})
54 if err != nil {
55 t.Fatal(err)
56 }
57
58 kindToApply := map[string]bool{
59 "ConfigMap": true,
60 "PersistentVolumeClaim": true,
61 "WorkflowTemplate": true,
62 "ClusterWorkflowTemplate": true,
63 }
64
65 err = fileutil.WalkManifests(ctx, "../../examples", func(path string, data []byte) error {
66 docs := splitYAMLDocuments(data)
67 for _, doc := range docs {
68 if len(doc) == 0 {
69 continue
70 }
71 obj := &unstructured.Unstructured{}
72 err = yaml.Unmarshal(doc, &obj)
73 if err != nil || obj == nil {
74 continue
75 }
76
77 if _, ok := kindToApply[obj.GetKind()]; !ok {
78 continue
79 }
80
81 gvr := obj.GroupVersionKind().GroupVersion().WithResource(strings.ToLower(obj.GetKind() + "s"))
82 if obj.GetKind() == "ClusterWorkflowTemplate" {
83 // cluster scoped resources don't need a namespace
84 _, err = dyn.Resource(gvr).
85 Apply(
86 ctx,
87 obj.GetName(),

Callers

nothing calls this directly

Calls 15

GetMethod · 0.95
DefaultRestConfigFunction · 0.92
NewControllerFunction · 0.92
TestContextFunction · 0.92
NewPersistenceFunction · 0.92
TokenNameFunction · 0.92
SplitWorkflowYAMLFileFunction · 0.92
NewGivenFunction · 0.92
NewForConfigOrDieFunction · 0.92
NewFunction · 0.92
splitYAMLDocumentsFunction · 0.85
GroupVersionKindMethod · 0.80

Tested by

no test coverage detected