Skip to content

Commit

Permalink
RHINENG-10439: update template test for environment id
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMraka committed Jun 5, 2024
1 parent 50c0a1d commit 43bf2dd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion base/database/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"app/base/utils"
"fmt"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -493,7 +494,7 @@ func DeleteSystem(t *testing.T, inventoryID string) {

func CreateTemplate(t *testing.T, account int, uuid string, inventoryIDs []string) {
template := &models.Template{
RhAccountID: account, UUID: uuid, Name: uuid,
RhAccountID: account, UUID: uuid, Name: uuid, EnvironmentID: strings.ReplaceAll(uuid, "-", ""),
}

tx := DB.Begin()
Expand Down
10 changes: 5 additions & 5 deletions dev/test_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ INSERT INTO baseline (id, rh_account_id, name, config, description) VALUES
(3, 1, 'baseline_1-3', '{"to_time": "2000-01-01T00:00:00+00:00"}', NULL),
(4, 3, 'baseline_3-4', '{"to_time": "2000-01-01T00:00:00+00:00"}', NULL);

INSERT INTO template (id, rh_account_id, uuid, name, description, config, creator) VALUES
(1, 1, '99900000-0000-0000-0000-000000000001', 'temp1-1', 'desc1', '{"to_time": "2010-09-22T00:00:00+00:00"}', 'user1'),
(2, 1, '99900000-0000-0000-0000-000000000002', 'temp2-1', 'desc2', '{"to_time": "2021-01-01T00:00:00+00:00"}', 'user2'),
(3, 1, '99900000-0000-0000-0000-000000000003', 'temp3-1', NULL, '{"to_time": "2000-01-01T00:00:00+00:00"}', 'user3'),
(4, 3, '99900000-0000-0000-0000-000000000004', 'temp4-3', 'desc4', '{"to_time": "2000-01-01T00:00:00+00:00"}', 'user4');
INSERT INTO template (id, rh_account_id, uuid, environment_id, name, description, config, creator) VALUES
(1, 1, '99900000-0000-0000-0000-000000000001', '99900000000000000000000000000001', 'temp1-1', 'desc1', '{"to_time": "2010-09-22T00:00:00+00:00"}', 'user1'),
(2, 1, '99900000-0000-0000-0000-000000000002', '99900000000000000000000000000002', 'temp2-1', 'desc2', '{"to_time": "2021-01-01T00:00:00+00:00"}', 'user2'),
(3, 1, '99900000-0000-0000-0000-000000000003', '99900000000000000000000000000003', 'temp3-1', NULL, '{"to_time": "2000-01-01T00:00:00+00:00"}', 'user3'),
(4, 3, '99900000-0000-0000-0000-000000000004', '99900000000000000000000000000004', 'temp4-3', 'desc4', '{"to_time": "2000-01-01T00:00:00+00:00"}', 'user4');

INSERT INTO system_platform (id, inventory_id, display_name, rh_account_id, reporter_id, vmaas_json, json_checksum, last_evaluation, last_upload, packages_installed, packages_installable, packages_applicable, third_party, baseline_id, baseline_uptodate, template_id) VALUES
(1, '00000000-0000-0000-0000-000000000001','00000000-0000-0000-0000-000000000001', 1, 1, '{ "package_list": [ "kernel-2.6.32-696.20.1.el6.x86_64" ], "repository_list": [ "rhel-6-server-rpms" ] }', '1', '2018-09-22 12:00:00-04', '2020-09-22 12:00:00-04',0,0,0, true, 1, true, 1),
Expand Down
13 changes: 8 additions & 5 deletions listener/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
"testing"
"time"

Expand All @@ -24,12 +25,14 @@ func createTempateMsg(t *testing.T, eventName, orgID string, nTemplates int) mqu
templates := make([]mqueue.TemplateResponse, nTemplates)
for i := 0; i < nTemplates; i++ {
description := fmt.Sprintf("Template%d description", i)
uuid := fmt.Sprintf("77777777-0000-0000-0000-00000000000%1d", i)
templates[i] = mqueue.TemplateResponse{
UUID: fmt.Sprintf("77777777-0000-0000-0000-00000000000%1d", i),
Name: fmt.Sprintf("Template%d", i),
OrgID: orgID,
Description: &description,
Date: time.Now(),
UUID: uuid,
EnvironmentID: strings.ReplaceAll(uuid, "-", ""),
Name: fmt.Sprintf("Template%d", i),
OrgID: orgID,
Description: &description,
Date: time.Now(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ var templates = []mqueue.TemplateResponse{
Version: "1",
Date: time.Now(),
RepositoryUUIDS: []string{"20000000-0000-0000-0000-000000000001"},
EnvironmentID: "10000000000000000000000000000001",
},
{
UUID: "10000000-0000-0000-0000-000000000002",
Expand All @@ -174,6 +175,7 @@ var templates = []mqueue.TemplateResponse{
Version: "1",
Date: time.Now(),
RepositoryUUIDS: []string{"20000000-0000-0000-0000-000000000001", "20000000-0000-0000-0000-000000000002"},
EnvironmentID: "10000000000000000000000000000002",
},
}

Expand Down

0 comments on commit 43bf2dd

Please sign in to comment.