From 499433aaae9cf55e358c09c0e8405741fab9237e Mon Sep 17 00:00:00 2001 From: srinandan Date: Mon, 7 Oct 2024 21:42:15 +0000 Subject: [PATCH] feat: exec test case #289 --- internal/client/integrations/testcases.go | 2 +- internal/cmd/integrations/executetestcase.go | 61 ++++++++++++++++++++ internal/cmd/integrations/testcases.go | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 internal/cmd/integrations/executetestcase.go diff --git a/internal/client/integrations/testcases.go b/internal/client/integrations/testcases.go index 443f0061..3d2c941d 100644 --- a/internal/client/integrations/testcases.go +++ b/internal/client/integrations/testcases.go @@ -48,7 +48,7 @@ func ListTestCases(name string, version string) (respBody []byte, err error) { return respBody, err } -func RunTestCase(name string, version string, testCaseID string) (respBody []byte, err error) { +func ExecuteTestCase(name string, version string, testCaseID string) (respBody []byte, err error) { u, _ := url.Parse(apiclient.GetBaseIntegrationURL()) u.Path = path.Join(u.Path, "integrations", name, "versions", version, "testCases", testCaseID, ":executeTest") respBody, err = apiclient.HttpClient(u.String(), "") diff --git a/internal/cmd/integrations/executetestcase.go b/internal/cmd/integrations/executetestcase.go new file mode 100644 index 00000000..e7e7f976 --- /dev/null +++ b/internal/cmd/integrations/executetestcase.go @@ -0,0 +1,61 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package integrations + +import ( + "internal/apiclient" + "internal/client/integrations" + + "github.com/spf13/cobra" +) + +// ExecuteTestCaseCmd to get integration flow +var ExecuteTestCaseCmd = &cobra.Command{ + Use: "execute", + Short: "Execute an integration flow version test case", + Long: "Execute an integration flow version test case", + Args: func(cmd *cobra.Command, args []string) (err error) { + cmdProject := cmd.Flag("proj") + cmdRegion := cmd.Flag("reg") + + if err = apiclient.SetRegion(cmdRegion.Value.String()); err != nil { + return err + } + + return apiclient.SetProjectID(cmdProject.Value.String()) + }, + RunE: func(cmd *cobra.Command, args []string) (err error) { + version := cmd.Flag("ver").Value.String() + name := cmd.Flag("name").Value.String() + testCaseID := cmd.Flag("test-case-id").Value.String() + _, err = integrations.ExecuteTestCase(name, version, testCaseID) + return err + }, +} + +func init() { + var name, version, testCaseID string + + ExecuteTestCaseCmd.Flags().StringVarP(&name, "name", "n", + "", "Integration flow name") + ExecuteTestCaseCmd.Flags().StringVarP(&version, "ver", "v", + "", "Integration flow version") + ExecuteTestCaseCmd.Flags().StringVarP(&testCaseID, "test-case-id", "c", + "", "Test Case ID") + _ = ExecuteTestCaseCmd.MarkFlagRequired("name") + _ = ExecuteTestCaseCmd.MarkFlagRequired("ver") + _ = ExecuteTestCaseCmd.MarkFlagRequired("test-case-id") + +} diff --git a/internal/cmd/integrations/testcases.go b/internal/cmd/integrations/testcases.go index aa8dbf94..9342589d 100644 --- a/internal/cmd/integrations/testcases.go +++ b/internal/cmd/integrations/testcases.go @@ -30,4 +30,5 @@ func init() { TestCasesCmd.AddCommand(DelTestCaseCmd) TestCasesCmd.AddCommand(ListTestCaseCmd) TestCasesCmd.AddCommand(CrtTestCaseCmd) + TestCasesCmd.AddCommand(ExecuteTestCaseCmd) }