github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/actor/pushaction/command_line_settings_test.go (about)

     1  package pushaction_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/actor/pushaction"
     5  	"code.cloudfoundry.org/cli/types"
     6  	"code.cloudfoundry.org/cli/util/manifest"
     7  
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/ginkgo/extensions/table"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("CommandLineSettings", func() {
    14  	var (
    15  		settings CommandLineSettings
    16  	)
    17  
    18  	BeforeEach(func() {
    19  		settings = CommandLineSettings{}
    20  	})
    21  
    22  	Describe("ApplicationPath", func() {
    23  		// more tests under command_line_settings_*OS*_test.go
    24  
    25  		Context("when ProvidedAppPath is *not* set", func() {
    26  			BeforeEach(func() {
    27  				settings.CurrentDirectory = "current-dir"
    28  			})
    29  
    30  			It("returns the CurrentDirectory", func() {
    31  				Expect(settings.ApplicationPath()).To(Equal("current-dir"))
    32  			})
    33  		})
    34  	})
    35  
    36  	DescribeTable("OverrideManifestSettings",
    37  		func(settings CommandLineSettings, input manifest.Application, output manifest.Application) {
    38  			Expect(settings.OverrideManifestSettings(input)).To(Equal(output))
    39  		},
    40  		Entry("overrides buildpack name",
    41  			CommandLineSettings{Buildpack: types.FilteredString{IsSet: true, Value: "sixpack"}},
    42  			manifest.Application{Buildpack: types.FilteredString{IsSet: true, Value: "not-sixpack"}},
    43  			manifest.Application{Buildpack: types.FilteredString{IsSet: true, Value: "sixpack"}},
    44  		),
    45  		Entry("passes through buildpack name",
    46  			CommandLineSettings{Buildpack: types.FilteredString{IsSet: false, Value: ""}},
    47  			manifest.Application{Buildpack: types.FilteredString{IsSet: true, Value: "not-sixpack"}},
    48  			manifest.Application{Buildpack: types.FilteredString{IsSet: true, Value: "not-sixpack"}},
    49  		),
    50  		Entry("overrides command",
    51  			CommandLineSettings{Command: types.FilteredString{IsSet: true, Value: "not-steve"}},
    52  			manifest.Application{Command: types.FilteredString{IsSet: true, Value: "steve"}},
    53  			manifest.Application{Command: types.FilteredString{IsSet: true, Value: "not-steve"}},
    54  		),
    55  		Entry("passes through command",
    56  			CommandLineSettings{},
    57  			manifest.Application{Command: types.FilteredString{IsSet: true, Value: "steve"}},
    58  			manifest.Application{Command: types.FilteredString{IsSet: true, Value: "steve"}},
    59  		),
    60  		Entry("overrides disk quota",
    61  			CommandLineSettings{DiskQuota: 1024},
    62  			manifest.Application{DiskQuota: types.NullByteSizeInMb{Value: 512, IsSet: true}},
    63  			manifest.Application{DiskQuota: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
    64  		),
    65  		Entry("passes through disk quota",
    66  			CommandLineSettings{},
    67  			manifest.Application{DiskQuota: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
    68  			manifest.Application{DiskQuota: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
    69  		),
    70  		Entry("overrides docker image",
    71  			CommandLineSettings{DockerImage: "not-steve"},
    72  			manifest.Application{DockerImage: "steve"},
    73  			manifest.Application{DockerImage: "not-steve"},
    74  		),
    75  		Entry("passes through docker image",
    76  			CommandLineSettings{},
    77  			manifest.Application{DockerImage: "steve"},
    78  			manifest.Application{DockerImage: "steve"},
    79  		),
    80  		Entry("overrides docker username",
    81  			CommandLineSettings{DockerUsername: "not-steve"},
    82  			manifest.Application{DockerUsername: "steve"},
    83  			manifest.Application{DockerUsername: "not-steve"},
    84  		),
    85  		Entry("passes through docker username",
    86  			CommandLineSettings{},
    87  			manifest.Application{DockerUsername: "steve"},
    88  			manifest.Application{DockerUsername: "steve"},
    89  		),
    90  		Entry("overrides docker password",
    91  			CommandLineSettings{DockerPassword: "not-steve"},
    92  			manifest.Application{DockerPassword: "steve"},
    93  			manifest.Application{DockerPassword: "not-steve"},
    94  		),
    95  		Entry("passes through docker password",
    96  			CommandLineSettings{},
    97  			manifest.Application{DockerPassword: "steve"},
    98  			manifest.Application{DockerPassword: "steve"},
    99  		),
   100  		Entry("overrides health check timeout",
   101  			CommandLineSettings{HealthCheckTimeout: 1024},
   102  			manifest.Application{HealthCheckTimeout: 512},
   103  			manifest.Application{HealthCheckTimeout: 1024},
   104  		),
   105  		Entry("passes through health check timeout",
   106  			CommandLineSettings{},
   107  			manifest.Application{HealthCheckTimeout: 1024},
   108  			manifest.Application{HealthCheckTimeout: 1024},
   109  		),
   110  		Entry("overrides health check type",
   111  			CommandLineSettings{HealthCheckType: "port"},
   112  			manifest.Application{HealthCheckType: "http"},
   113  			manifest.Application{HealthCheckType: "port"},
   114  		),
   115  		Entry("passes through health check type",
   116  			CommandLineSettings{},
   117  			manifest.Application{HealthCheckType: "http"},
   118  			manifest.Application{HealthCheckType: "http"},
   119  		),
   120  		Entry("overrides instances",
   121  			CommandLineSettings{Instances: types.NullInt{Value: 1024, IsSet: true}},
   122  			manifest.Application{Instances: types.NullInt{Value: 512, IsSet: true}},
   123  			manifest.Application{Instances: types.NullInt{Value: 1024, IsSet: true}},
   124  		),
   125  		Entry("passes through instances",
   126  			CommandLineSettings{},
   127  			manifest.Application{Instances: types.NullInt{Value: 1024, IsSet: true}},
   128  			manifest.Application{Instances: types.NullInt{Value: 1024, IsSet: true}},
   129  		),
   130  		Entry("overrides memory",
   131  			CommandLineSettings{Memory: 1024},
   132  			manifest.Application{Memory: types.NullByteSizeInMb{Value: 512, IsSet: true}},
   133  			manifest.Application{Memory: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
   134  		),
   135  		Entry("passes through memory",
   136  			CommandLineSettings{},
   137  			manifest.Application{Memory: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
   138  			manifest.Application{Memory: types.NullByteSizeInMb{Value: 1024, IsSet: true}},
   139  		),
   140  		Entry("overrides name",
   141  			CommandLineSettings{Name: "not-steve"},
   142  			manifest.Application{Name: "steve"},
   143  			manifest.Application{Name: "not-steve"},
   144  		),
   145  		Entry("passes through name",
   146  			CommandLineSettings{},
   147  			manifest.Application{Name: "steve"},
   148  			manifest.Application{Name: "steve"},
   149  		),
   150  		Entry("overrides stack name",
   151  			CommandLineSettings{StackName: "not-steve"},
   152  			manifest.Application{StackName: "steve"},
   153  			manifest.Application{StackName: "not-steve"},
   154  		),
   155  		Entry("passes through stack name",
   156  			CommandLineSettings{},
   157  			manifest.Application{StackName: "steve"},
   158  			manifest.Application{StackName: "steve"},
   159  		),
   160  	)
   161  
   162  	Describe("OverrideManifestSettings", func() {
   163  		// more tests under command_line_settings_*OS*_test.go
   164  
   165  		var input, output manifest.Application
   166  
   167  		BeforeEach(func() {
   168  			input.Name = "steve"
   169  		})
   170  
   171  		JustBeforeEach(func() {
   172  			output = settings.OverrideManifestSettings(input)
   173  		})
   174  
   175  		Describe("name", func() {
   176  			Context("when the command line settings provides a name", func() {
   177  				BeforeEach(func() {
   178  					settings.Name = "not-steve"
   179  				})
   180  
   181  				It("overrides the name", func() {
   182  					Expect(output.Name).To(Equal("not-steve"))
   183  				})
   184  			})
   185  
   186  			Context("when the command line settings name is blank", func() {
   187  				It("passes the manifest name through", func() {
   188  					Expect(output.Name).To(Equal("steve"))
   189  				})
   190  			})
   191  		})
   192  	})
   193  })