Skip to content

Commit

Permalink
feat: exec test case #289
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Oct 7, 2024
1 parent 4f74005 commit 499433a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/client/integrations/testcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(), "")
Expand Down
61 changes: 61 additions & 0 deletions internal/cmd/integrations/executetestcase.go
Original file line number Diff line number Diff line change
@@ -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")

}
1 change: 1 addition & 0 deletions internal/cmd/integrations/testcases.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ func init() {
TestCasesCmd.AddCommand(DelTestCaseCmd)
TestCasesCmd.AddCommand(ListTestCaseCmd)
TestCasesCmd.AddCommand(CrtTestCaseCmd)
TestCasesCmd.AddCommand(ExecuteTestCaseCmd)
}

0 comments on commit 499433a

Please sign in to comment.