Skip to content

Commit c0ae875

Browse files
committed
unit tests
1 parent 4414f40 commit c0ae875

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

coderd/templateversions_test.go

+43
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
138138
require.Len(t, auditor.AuditLogs(), 2)
139139
assert.Equal(t, database.AuditActionCreate, auditor.AuditLogs()[1].Action)
140140
})
141+
141142
t.Run("Example", func(t *testing.T) {
142143
t.Parallel()
143144
client := coderdtest.New(t, nil)
@@ -1453,3 +1454,45 @@ func TestTemplateVersionPatch(t *testing.T) {
14531454
require.Error(t, err)
14541455
})
14551456
}
1457+
1458+
func TestTemplateVersionWarnings(t *testing.T) {
1459+
t.Parallel()
1460+
1461+
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
1462+
user := coderdtest.CreateFirstUser(t, client)
1463+
1464+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
1465+
defer cancel()
1466+
1467+
templateVersion := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
1468+
Parse: []*proto.Parse_Response{{
1469+
Type: &proto.Parse_Response_Complete{
1470+
Complete: &proto.Parse_Complete{
1471+
ParameterSchemas: []*proto.ParameterSchema{
1472+
{
1473+
AllowOverrideSource: true,
1474+
Name: "example",
1475+
Description: "description 1",
1476+
DefaultSource: &proto.ParameterSource{
1477+
Scheme: proto.ParameterSource_DATA,
1478+
Value: "tomato",
1479+
},
1480+
DefaultDestination: &proto.ParameterDestination{
1481+
Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE,
1482+
},
1483+
},
1484+
},
1485+
},
1486+
},
1487+
}},
1488+
ProvisionApply: echo.ProvisionComplete,
1489+
ProvisionPlan: echo.ProvisionComplete,
1490+
})
1491+
coderdtest.AwaitTemplateVersionJob(t, client, templateVersion.ID)
1492+
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, templateVersion.ID)
1493+
1494+
templateVersion, err := client.TemplateVersion(ctx, template.ActiveVersionID)
1495+
require.NoError(t, err)
1496+
1497+
require.Contains(t, templateVersion.Warnings, codersdk.TemplateVersionWarningDeprecatedParameters)
1498+
}

site/src/components/TemplateVersionWarnings/TemplateVersionWarnings.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FC } from "react"
22
import * as TypesGen from "api/typesGenerated"
33
import { AlertBanner } from "components/AlertBanner/AlertBanner"
44
import { Maybe } from "components/Conditionals/Maybe"
5-
import Link from "@material-ui/core/Link"
5+
import Link from "@mui/material/Link"
66

77
export interface TemplateVersionWarnings {
88
warnings?: TypesGen.TemplateVersionWarning[]

0 commit comments

Comments
 (0)