github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/actor/v7pushaction/handle_log_rate_limit_override_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 "code.cloudfoundry.org/cli/command/translatableerror" 5 "code.cloudfoundry.org/cli/util/manifestparser" 6 7 . "code.cloudfoundry.org/cli/actor/v7pushaction" 8 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("HandleLogRateLimitOverride", func() { 14 var ( 15 originalManifest manifestparser.Manifest 16 transformedManifest manifestparser.Manifest 17 overrides FlagOverrides 18 executeErr error 19 ) 20 21 BeforeEach(func() { 22 originalManifest = manifestparser.Manifest{} 23 overrides = FlagOverrides{} 24 }) 25 26 JustBeforeEach(func() { 27 transformedManifest, executeErr = HandleLogRateLimitOverride(originalManifest, overrides) 28 }) 29 30 When("log rate limit is not set on a flag override", func() { 31 BeforeEach(func() { 32 originalManifest.Applications = []manifestparser.Application{ 33 { 34 Processes: []manifestparser.Process{ 35 {Type: "web"}, 36 {Type: "worker", LogRateLimit: "1B"}, 37 }, 38 }, 39 } 40 }) 41 42 It("does not change the manifest", func() { 43 Expect(executeErr).ToNot(HaveOccurred()) 44 Expect(transformedManifest.Applications).To(ConsistOf( 45 manifestparser.Application{ 46 Processes: []manifestparser.Process{ 47 {Type: "web"}, 48 {Type: "worker", LogRateLimit: "1B"}, 49 }, 50 }, 51 )) 52 }) 53 }) 54 55 When("manifest web process does not specify log rate limit", func() { 56 BeforeEach(func() { 57 overrides.LogRateLimit = "64K" 58 59 originalManifest.Applications = []manifestparser.Application{ 60 { 61 Processes: []manifestparser.Process{ 62 {Type: "web"}, 63 }, 64 }, 65 } 66 }) 67 68 It("changes the log rate limit of the web process in the manifest", func() { 69 Expect(executeErr).ToNot(HaveOccurred()) 70 Expect(transformedManifest.Applications).To(ConsistOf( 71 manifestparser.Application{ 72 Processes: []manifestparser.Process{ 73 {Type: "web", LogRateLimit: "64K"}, 74 }, 75 }, 76 )) 77 }) 78 }) 79 80 When("manifest app has only non-web processes", func() { 81 BeforeEach(func() { 82 overrides.LogRateLimit = "32B" 83 84 originalManifest.Applications = []manifestparser.Application{ 85 { 86 Processes: []manifestparser.Process{ 87 {Type: "worker"}, 88 }, 89 }, 90 } 91 }) 92 93 It("changes the log rate limit of the app in the manifest", func() { 94 Expect(executeErr).ToNot(HaveOccurred()) 95 Expect(transformedManifest.Applications).To(ConsistOf( 96 manifestparser.Application{ 97 LogRateLimit: "32B", 98 Processes: []manifestparser.Process{ 99 {Type: "worker"}, 100 }, 101 }, 102 )) 103 }) 104 }) 105 106 When("manifest app has web and non-web processes", func() { 107 BeforeEach(func() { 108 overrides.LogRateLimit = "4MB" 109 110 originalManifest.Applications = []manifestparser.Application{ 111 { 112 Processes: []manifestparser.Process{ 113 {Type: "worker"}, 114 {Type: "web"}, 115 }, 116 LogRateLimit: "1GB", 117 }, 118 } 119 }) 120 121 It("changes the log rate limit of the web process in the manifest", func() { 122 Expect(executeErr).ToNot(HaveOccurred()) 123 Expect(transformedManifest.Applications).To(ConsistOf( 124 manifestparser.Application{ 125 Processes: []manifestparser.Process{ 126 {Type: "worker"}, 127 {Type: "web", LogRateLimit: "4MB"}, 128 }, 129 LogRateLimit: "1GB", 130 }, 131 )) 132 }) 133 }) 134 135 When("there are multiple apps in the manifest", func() { 136 BeforeEach(func() { 137 overrides.LogRateLimit = "64M" 138 139 originalManifest.Applications = []manifestparser.Application{ 140 {}, 141 {}, 142 } 143 }) 144 145 It("returns an error", func() { 146 Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) 147 }) 148 }) 149 })