Fixing tests after adding labels to release fixture

Signed-off-by: Dmitry Chepurovskiy <dm3ch@dm3ch.net>
Signed-off-by: Dmitry Chepurovskiy <me@dm3ch.net>
pull/10533/head
Dmitry Chepurovskiy 3 years ago committed by Dmitry Chepurovskiy
parent 2f29ccb9d0
commit 512970ab40
No known key found for this signature in database
GPG Key ID: 5B3A5FDCBFF9B3A4

@ -244,6 +244,9 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*v1.ConfigM
lbs.init() lbs.init()
} }
// apply custom labels
lbs.fromMap(rls.Labels)
// apply labels // apply labels
lbs.set("name", rls.Name) lbs.set("name", rls.Name)
lbs.set("owner", owner) lbs.set("owner", owner)

@ -41,8 +41,8 @@ func releaseStub(name string, vers int, namespace string, status rspb.Status) *r
Namespace: namespace, Namespace: namespace,
Info: &rspb.Info{Status: status}, Info: &rspb.Info{Status: status},
Labels: map[string]string{ Labels: map[string]string{
"k1": "v1", "key1": "val1",
"k2": "v2", "key2": "val2",
}, },
} }
} }

@ -226,6 +226,9 @@ func newSecretsObject(key string, rls *rspb.Release, lbs labels) (*v1.Secret, er
lbs.init() lbs.init()
} }
// apply custom labels
lbs.fromMap(rls.Labels)
// apply labels // apply labels
lbs.set("name", rls.Name) lbs.set("name", rls.Name)
lbs.set("owner", owner) lbs.set("owner", owner)

@ -598,6 +598,11 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) {
return release, err return release, err
} }
if release.Labels, err = s.getReleaseCustomLabels(key, s.namespace); err != nil {
s.Log("failed to get release %s/%s custom labels: %v", s.namespace, key, err)
return nil, err
}
deleteCustomLabelsQuery, args, err := s.statementBuilder. deleteCustomLabelsQuery, args, err := s.statementBuilder.
Delete(sqlCustomLabelsTableName). Delete(sqlCustomLabelsTableName).
Where(sq.Eq{sqlCustomLabelsTableReleaseKeyColumn: key}). Where(sq.Eq{sqlCustomLabelsTableReleaseKeyColumn: key}).

@ -196,7 +196,7 @@ func TestSqlCreate(t *testing.T) {
sqlCustomLabelsTableKeyColumn, sqlCustomLabelsTableKeyColumn,
sqlCustomLabelsTableValueColumn, sqlCustomLabelsTableValueColumn,
) )
for k, v := range rel.Labels { for k, v := range filterSystemLabels(rel.Labels) {
mock. mock.
ExpectExec(regexp.QuoteMeta(labelsQuery)). ExpectExec(regexp.QuoteMeta(labelsQuery)).
WithArgs(key, rel.Namespace, k, v). WithArgs(key, rel.Namespace, k, v).
@ -478,6 +478,8 @@ func TestSqlDelete(t *testing.T) {
WithArgs(key, namespace). WithArgs(key, namespace).
WillReturnResult(sqlmock.NewResult(0, 1)) WillReturnResult(sqlmock.NewResult(0, 1))
mockGetReleaseCustomLabels(mock, key, namespace, rel.Labels)
deleteLabelsQuery := fmt.Sprintf( deleteLabelsQuery := fmt.Sprintf(
"DELETE FROM %s WHERE %s = $1 AND %s = $2", "DELETE FROM %s WHERE %s = $1 AND %s = $2",
sqlCustomLabelsTableName, sqlCustomLabelsTableName,

@ -34,8 +34,8 @@ func TestIsSystemLabel(t *testing.T) {
func TestFilterSystemLabels(t *testing.T) { func TestFilterSystemLabels(t *testing.T) {
var tests = [][2]map[string]string{ var tests = [][2]map[string]string{
{nil, nil}, {nil, map[string]string{}},
{map[string]string{}, nil}, {map[string]string{}, map[string]string{}},
{map[string]string{ {map[string]string{
"name": "name", "name": "name",
"owner": "owner", "owner": "owner",
@ -43,7 +43,7 @@ func TestFilterSystemLabels(t *testing.T) {
"version": "version", "version": "version",
"createdAt": "createdAt", "createdAt": "createdAt",
"modifiedAt": "modifiedAt", "modifiedAt": "modifiedAt",
}, nil}, }, map[string]string{}},
{map[string]string{ {map[string]string{
"StaTus": "status", "StaTus": "status",
"name": "name", "name": "name",

Loading…
Cancel
Save