github.com/cloudfoundry-attic/ltc@v0.0.0-20151123212628-098adc7919fc/cluster_test/command_factory/cluster_test_command_factory.go (about)

     1  package command_factory
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/cloudfoundry-incubator/ltc/cluster_test"
     7  	"github.com/codegangsta/cli"
     8  )
     9  
    10  type ClusterTestCommandFactory struct {
    11  	clusterTestRunner cluster_test.ClusterTestRunner
    12  }
    13  
    14  func NewClusterTestCommandFactory(testRunner cluster_test.ClusterTestRunner) *ClusterTestCommandFactory {
    15  	return &ClusterTestCommandFactory{testRunner}
    16  }
    17  
    18  func (factory *ClusterTestCommandFactory) MakeClusterTestCommand() cli.Command {
    19  
    20  	testFlags := []cli.Flag{
    21  		cli.DurationFlag{
    22  			Name:  "timeout, t",
    23  			Usage: "Duration of time tests will wait for lattice to respond",
    24  			Value: time.Minute * 5,
    25  		},
    26  		cli.BoolFlag{
    27  			Name:  "verbose, v",
    28  			Usage: "Verbose mode",
    29  		},
    30  	}
    31  
    32  	cliCommand := cli.Command{
    33  		Name:        "test",
    34  		Aliases:     []string{"te"},
    35  		Usage:       "Runs test suite against targeted lattice cluster",
    36  		Description: "ltc test [-v] [--timeout=<timeout>] [--cli-help]",
    37  		Action:      factory.runIntegrationTests,
    38  		Flags:       testFlags,
    39  	}
    40  
    41  	return cliCommand
    42  }
    43  
    44  func (factory *ClusterTestCommandFactory) runIntegrationTests(context *cli.Context) {
    45  	factory.clusterTestRunner.Run(context.Duration("timeout"), context.Bool("verbose"))
    46  }