github.com/appscode/helm@v3.0.0-alpha.1+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 timestamp1 := time.Unix(1452902400, 0).UTC() 30 timestamp2 := time.Unix(1452902401, 0).UTC() 31 chartInfo := &chart.Chart{ 32 Metadata: &chart.Metadata{ 33 Name: "chickadee", 34 Version: "1.0.0", 35 }, 36 } 37 releaseFixture := []*release.Release{ 38 { 39 Name: "starlord", 40 Version: 1, 41 Namespace: defaultNamespace, 42 Info: &release.Info{ 43 LastDeployed: timestamp1, 44 Status: release.StatusSuperseded, 45 }, 46 Chart: chartInfo, 47 }, 48 { 49 Name: "starlord", 50 Version: 2, 51 Namespace: defaultNamespace, 52 Info: &release.Info{ 53 LastDeployed: timestamp1, 54 Status: release.StatusDeployed, 55 }, 56 Chart: chartInfo, 57 }, 58 { 59 Name: "groot", 60 Version: 1, 61 Namespace: defaultNamespace, 62 Info: &release.Info{ 63 LastDeployed: timestamp2, 64 Status: release.StatusUninstalled, 65 }, 66 Chart: chartInfo, 67 }, 68 { 69 Name: "gamora", 70 Version: 1, 71 Namespace: defaultNamespace, 72 Info: &release.Info{ 73 LastDeployed: timestamp1, 74 Status: release.StatusSuperseded, 75 }, 76 Chart: chartInfo, 77 }, 78 { 79 Name: "rocket", 80 Version: 1, 81 Namespace: defaultNamespace, 82 Info: &release.Info{ 83 LastDeployed: timestamp2, 84 Status: release.StatusFailed, 85 }, 86 Chart: chartInfo, 87 }, 88 { 89 Name: "drax", 90 Version: 1, 91 Namespace: defaultNamespace, 92 Info: &release.Info{ 93 LastDeployed: timestamp1, 94 Status: release.StatusUninstalling, 95 }, 96 Chart: chartInfo, 97 }, 98 { 99 Name: "thanos", 100 Version: 1, 101 Namespace: defaultNamespace, 102 Info: &release.Info{ 103 LastDeployed: timestamp1, 104 Status: release.StatusPendingInstall, 105 }, 106 Chart: chartInfo, 107 }, 108 } 109 110 tests := []cmdTestCase{{ 111 name: "list releases", 112 cmd: "list", 113 golden: "output/list.txt", 114 rels: releaseFixture, 115 }, { 116 name: "list all releases", 117 cmd: "list --all", 118 golden: "output/list-all.txt", 119 rels: releaseFixture, 120 }, { 121 name: "list releases sorted by release date", 122 cmd: "list --date", 123 golden: "output/list-date.txt", 124 rels: releaseFixture, 125 }, { 126 name: "list failed releases", 127 cmd: "list --failed", 128 golden: "output/list-failed.txt", 129 rels: releaseFixture, 130 }, { 131 name: "list filtered releases", 132 cmd: "list --filter='.*'", 133 golden: "output/list-filter.txt", 134 rels: releaseFixture, 135 }, { 136 name: "list releases, limited to one release", 137 cmd: "list --max 1", 138 golden: "output/list-max.txt", 139 rels: releaseFixture, 140 }, { 141 name: "list releases, offset by one", 142 cmd: "list --offset 1", 143 golden: "output/list-offset.txt", 144 rels: releaseFixture, 145 }, { 146 name: "list pending releases", 147 cmd: "list --pending", 148 golden: "output/list-pending.txt", 149 rels: releaseFixture, 150 }, { 151 name: "list releases in reverse order", 152 cmd: "list --reverse", 153 golden: "output/list-reverse.txt", 154 rels: releaseFixture, 155 }, { 156 name: "list releases in short output format", 157 cmd: "list --short", 158 golden: "output/list-short.txt", 159 rels: releaseFixture, 160 }, { 161 name: "list superseded releases", 162 cmd: "list --superseded", 163 golden: "output/list-superseded.txt", 164 rels: releaseFixture, 165 }, { 166 name: "list uninstalled releases", 167 cmd: "list --uninstalled", 168 golden: "output/list-uninstalled.txt", 169 rels: releaseFixture, 170 }, { 171 name: "list releases currently uninstalling", 172 cmd: "list --uninstalling", 173 golden: "output/list-uninstalling.txt", 174 rels: releaseFixture, 175 }} 176 runTestCmd(t, tests) 177 }