github.com/unionj-cloud/go-doudou@v1.3.8-0.20221011095552-0088008e5b31/cmd/httptest.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/spf13/cobra"
     5  	"github.com/unionj-cloud/go-doudou/cmd/internal/svc"
     6  )
     7  
     8  var postmanCollectionPath string
     9  var dotenvPath string
    10  
    11  // testCmd generates http client code
    12  var testCmd = &cobra.Command{
    13  	Use:   "test",
    14  	Short: "generates integration testing code from postman collection v2.1 compatible file",
    15  	Long:  ``,
    16  	Run: func(cmd *cobra.Command, args []string) {
    17  		s := svc.Svc{
    18  			PostmanCollectionPath: postmanCollectionPath,
    19  			DotenvPath:            dotenvPath,
    20  		}
    21  		s.GenIntegrationTestingCode()
    22  	},
    23  }
    24  
    25  func init() {
    26  	httpCmd.AddCommand(testCmd)
    27  
    28  	testCmd.Flags().StringVar(&postmanCollectionPath, "collection", "", `postman collection v2.1 compatible file disk path`)
    29  	testCmd.Flags().StringVar(&dotenvPath, "dotenv", "", `dotenv format config file disk path only for integration testing purpose`)
    30  	testCmd.MarkFlagRequired("collection")
    31  	testCmd.MarkFlagRequired("dotenv")
    32  }