MCPcopy
hub / github.com/helm/helm / TestSQLList

Function TestSQLList

pkg/storage/driver/sql_test.go:113–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

111}
112
113func TestSQLList(t *testing.T) {
114 releases := []*rspb.Release{}
115 releases = append(releases, releaseStub("key-1", 1, "default", common.StatusUninstalled))
116 releases = append(releases, releaseStub("key-2", 1, "default", common.StatusUninstalled))
117 releases = append(releases, releaseStub("key-3", 1, "default", common.StatusDeployed))
118 releases = append(releases, releaseStub("key-4", 1, "default", common.StatusDeployed))
119 releases = append(releases, releaseStub("key-5", 1, "default", common.StatusSuperseded))
120 releases = append(releases, releaseStub("key-6", 1, "default", common.StatusSuperseded))
121
122 sqlDriver, mock := newTestFixtureSQL(t)
123
124 for range 3 {
125 query := fmt.Sprintf(
126 "SELECT %s, %s, %s FROM %s WHERE %s = $1 AND %s = $2",
127 sqlReleaseTableKeyColumn,
128 sqlReleaseTableNamespaceColumn,
129 sqlReleaseTableBodyColumn,
130 sqlReleaseTableName,
131 sqlReleaseTableOwnerColumn,
132 sqlReleaseTableNamespaceColumn,
133 )
134
135 rows := mock.NewRows([]string{
136 sqlReleaseTableBodyColumn,
137 })
138 for _, r := range releases {
139 body, _ := encodeRelease(r)
140 rows.AddRow(body)
141 }
142 mock.
143 ExpectQuery(regexp.QuoteMeta(query)).
144 WithArgs(sqlReleaseDefaultOwner, sqlDriver.namespace).
145 WillReturnRows(rows).RowsWillBeClosed()
146
147 for _, r := range releases {
148 mockGetReleaseCustomLabels(mock, "", r.Namespace, r.Labels)
149 }
150 }
151
152 // list all deleted releases
153 del, err := sqlDriver.List(func(rel release.Releaser) bool {
154 rls := convertReleaserToV1(t, rel)
155 return rls.Info.Status == common.StatusUninstalled
156 })
157 // check
158 if err != nil {
159 t.Errorf("Failed to list deleted: %v", err)
160 }
161 if len(del) != 2 {
162 t.Errorf("Expected 2 deleted, got %d:\n%v\n", len(del), del)
163 }
164
165 // list all deployed releases
166 dpl, err := sqlDriver.List(func(rel release.Releaser) bool {
167 rls := convertReleaserToV1(t, rel)
168 return rls.Info.Status == common.StatusDeployed
169 })
170 // check

Callers

nothing calls this directly

Calls 7

newTestFixtureSQLFunction · 0.85
encodeReleaseFunction · 0.85
convertReleaserToV1Function · 0.85
FatalfMethod · 0.80
releaseStubFunction · 0.70
ListMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…