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()
}
// apply custom labels
lbs.fromMap(rls.Labels)
// apply labels
lbs.set("name", rls.Name)
lbs.set("owner", owner)

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

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

@ -598,6 +598,11 @@ func (s *SQL) Delete(key string) (*rspb.Release, error) {
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.
Delete(sqlCustomLabelsTableName).
Where(sq.Eq{sqlCustomLabelsTableReleaseKeyColumn: key}).

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

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

Loading…
Cancel
Save