12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package test
- import (
- "git.sxidc.com/go-tools/argo-api"
- "git.sxidc.com/go-tools/argo-api/client"
- "github.com/pkg/errors"
- "testing"
- )
- func TestWorkflowTemplate(t *testing.T) {
- err := argo.Init(kubeConfig)
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- defer argo.Destroy()
- err = argo.GetInstance().LintWorkflowTemplate(client.LintWorkflowTemplateParams{
- Namespace: namespace,
- TemplateDefinition: templateYamlStr,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- err = argo.GetInstance().CreateWorkflowTemplate(client.CreateWorkflowTemplateParams{
- Namespace: namespace,
- TemplateDefinition: templateYamlStr,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- defer func() {
- err := argo.GetInstance().DeleteWorkflowTemplate(client.DeleteWorkflowTemplateParams{
- Namespace: namespace,
- Name: workflowTemplateName,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- }()
- wfts, err := argo.GetInstance().GetWorkflowTemplatesInNamespace(client.GetWorkflowTemplatesInNamespaceParams{
- Namespace: namespace,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- if len(wfts) != 1 {
- t.Fatalf("%+v\n", errors.Errorf("数量不一致: %v", len(wfts)))
- }
- wft, err := argo.GetInstance().GetWorkflowTemplate(client.GetWorkflowTemplateParams{
- Namespace: namespace,
- Name: workflowTemplateName,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- if wft.Namespace != wfts[0].Namespace {
- t.Fatalf("%+v\n", errors.Errorf("命名空间不一致: one: %s other: %s", wft.Namespace, wfts[0].Namespace))
- }
- if wft.Name != wfts[0].Name {
- t.Fatalf("%+v\n", errors.Errorf("名称不一致: one: %s other: %s", wft.Name, wfts[0].Name))
- }
- err = argo.GetInstance().UpdateWorkflowTemplate(client.UpdateWorkflowTemplateParams{
- Namespace: namespace,
- Name: workflowTemplateName,
- WorkflowTemplate: wft,
- })
- if err != nil {
- t.Fatalf("%+v\n", err)
- }
- }
|