github.com/doitroot/helm@v3.0.0-beta.3+incompatible/cmd/helm/list_test.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "testing" 21 "time" 22 23 "helm.sh/helm/pkg/chart" 24 "helm.sh/helm/pkg/release" 25 ) 26 27 func TestListCmd(t *testing.T) { 28 defaultNamespace := "default" 29 30 sampleTimeSeconds := int64(1452902400) 31 timestamp1 := time.Unix(sampleTimeSeconds+1, 0).UTC() 32 timestamp2 := time.Unix(sampleTimeSeconds+2, 0).UTC() 33 timestamp3 := time.Unix(sampleTimeSeconds+3, 0).UTC() 34 timestamp4 := time.Unix(sampleTimeSeconds+4, 0).UTC() 35 chartInfo := &chart.Chart{ 36 Metadata: &chart.Metadata{ 37 Name: "chickadee", 38 Version: "1.0.0", 39 }, 40 } 41 42 releaseFixture := []*release.Release{ 43 { 44 Name: "starlord", 45 Version: 1, 46 Namespace: defaultNamespace, 47 Info: &release.Info{ 48 LastDeployed: timestamp1, 49 Status: release.StatusSuperseded, 50 }, 51 Chart: chartInfo, 52 }, 53 { 54 Name: "starlord", 55 Version: 2, 56 Namespace: defaultNamespace, 57 Info: &release.Info{ 58 LastDeployed: timestamp1, 59 Status: release.StatusDeployed, 60 }, 61 Chart: chartInfo, 62 }, 63 { 64 Name: "groot", 65 Version: 1, 66 Namespace: defaultNamespace, 67 Info: &release.Info{ 68 LastDeployed: timestamp1, 69 Status: release.StatusUninstalled, 70 }, 71 Chart: chartInfo, 72 }, 73 { 74 Name: "gamora", 75 Version: 1, 76 Namespace: defaultNamespace, 77 Info: &release.Info{ 78 LastDeployed: timestamp1, 79 Status: release.StatusSuperseded, 80 }, 81 Chart: chartInfo, 82 }, 83 { 84 Name: "rocket", 85 Version: 1, 86 Namespace: defaultNamespace, 87 Info: &release.Info{ 88 LastDeployed: timestamp2, 89 Status: release.StatusFailed, 90 }, 91 Chart: chartInfo, 92 }, 93 { 94 Name: "drax", 95 Version: 1, 96 Namespace: defaultNamespace, 97 Info: &release.Info{ 98 LastDeployed: timestamp1, 99 Status: release.StatusUninstalling, 100 }, 101 Chart: chartInfo, 102 }, 103 { 104 Name: "thanos", 105 Version: 1, 106 Namespace: defaultNamespace, 107 Info: &release.Info{ 108 LastDeployed: timestamp1, 109 Status: release.StatusPendingInstall, 110 }, 111 Chart: chartInfo, 112 }, 113 { 114 Name: "hummingbird", 115 Version: 1, 116 Namespace: defaultNamespace, 117 Info: &release.Info{ 118 LastDeployed: timestamp3, 119 Status: release.StatusDeployed, 120 }, 121 Chart: chartInfo, 122 }, 123 { 124 Name: "iguana", 125 Version: 2, 126 Namespace: defaultNamespace, 127 Info: &release.Info{ 128 LastDeployed: timestamp4, 129 Status: release.StatusDeployed, 130 }, 131 Chart: chartInfo, 132 }, 133 } 134 135 tests := []cmdTestCase{{ 136 name: "list releases", 137 cmd: "list", 138 golden: "output/list.txt", 139 rels: releaseFixture, 140 }, { 141 name: "list all releases", 142 cmd: "list --all", 143 golden: "output/list-all.txt", 144 rels: releaseFixture, 145 }, { 146 name: "list releases sorted by release date", 147 cmd: "list --date", 148 golden: "output/list-date.txt", 149 rels: releaseFixture, 150 }, { 151 name: "list failed releases", 152 cmd: "list --failed", 153 golden: "output/list-failed.txt", 154 rels: releaseFixture, 155 }, { 156 name: "list filtered releases", 157 cmd: "list --filter='.*'", 158 golden: "output/list-filter.txt", 159 rels: releaseFixture, 160 }, { 161 name: "list releases, limited to one release", 162 cmd: "list --max 1", 163 golden: "output/list-max.txt", 164 rels: releaseFixture, 165 }, { 166 name: "list releases, offset by one", 167 cmd: "list --offset 1", 168 golden: "output/list-offset.txt", 169 rels: releaseFixture, 170 }, { 171 name: "list pending releases", 172 cmd: "list --pending", 173 golden: "output/list-pending.txt", 174 rels: releaseFixture, 175 }, { 176 name: "list releases in reverse order", 177 cmd: "list --reverse", 178 golden: "output/list-reverse.txt", 179 rels: releaseFixture, 180 }, { 181 name: "list releases sorted by reversed release date", 182 cmd: "list --date --reverse", 183 golden: "output/list-date-reversed.txt", 184 rels: releaseFixture, 185 }, { 186 name: "list releases in short output format", 187 cmd: "list --short", 188 golden: "output/list-short.txt", 189 rels: releaseFixture, 190 }, { 191 name: "list superseded releases", 192 cmd: "list --superseded", 193 golden: "output/list-superseded.txt", 194 rels: releaseFixture, 195 }, { 196 name: "list uninstalled releases", 197 cmd: "list --uninstalled", 198 golden: "output/list-uninstalled.txt", 199 rels: releaseFixture, 200 }, { 201 name: "list releases currently uninstalling", 202 cmd: "list --uninstalling", 203 golden: "output/list-uninstalling.txt", 204 rels: releaseFixture, 205 }} 206 runTestCmd(t, tests) 207 }