You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE PROCEDURE [___TESTCLASS___].[___TESTNAME___]
ASBEGINSET NOCOUNT ON;
----- ASSEMBLE ------------------------------------------------- Create the tables
CREATE TABLE #actual
(
[ParameterName] NVARCHAR(128) NOT NULL,
[DataType] sysname NOT NULL,
[MaxLength] SMALLINTNOT NULL,
[Precision] TINYINT NOT NULL,
[Scale] TINYINT NOT NULL
);
CREATE TABLE #expected
(
[ParameterName] NVARCHAR(128) NOT NULL,
[DataType] sysname NOT NULL,
[MaxLength] SMALLINTNOT NULL,
[Precision] TINYINT NOT NULL,
[Scale] TINYINT NOT NULL
);
INSERT INTO#expected
(
ParameterName,
DataType,
MaxLength,
Precision,
Scale
)
VALUES
___PARAMETERS___
----- ACT ----------------------------------------------------INSERT INTO#actual
(
ParameterName,
DataType,
MaxLength,
Precision,
Scale
)
SELECTpm.nameAS ParameterName,
t.nameAS DataType,
pm.max_lengthAS MaxLength,
pm.precisionAS [Precision],
pm.scaleAS Scale
FROM___DATABASE___.sys.parameters AS pm
INNER JOIN___DATABASE___.sys.sql_modules AS sm
ONsm.object_id=pm.object_idINNER JOIN___DATABASE___.sys.objects AS o
ONsm.object_id=o.object_idINNER JOIN___DATABASE___.sys.schemas AS s
ONs.schema_id=o.schema_idINNER JOIN___DATABASE___.sys.types AS t
ONpm.system_type_id=t.system_type_idANDpm.user_type_id=t.user_type_idWHEREs.name='___SCHEMA___'ANDo.name='___NAME___'ANDpm.name<>'';
----- ASSERT --------------------------------------------------- Assert to have the same values
EXEC tSQLt.AssertEqualsTable @Expected ='#expected', @Actual ='#actual';
END;
ProcedureParameterTest.template
CREATE PROCEDURE [___TESTCLASS___].[___TESTNAME___]
ASBEGINSET NOCOUNT ON;
----- ASSEMBLE ------------------------------------------------- Create the tables
CREATE TABLE #actual
(
[ParameterName] NVARCHAR(128) NOT NULL,
[DataType] sysname NOT NULL,
[MaxLength] SMALLINTNOT NULL,
[Precision] TINYINT NOT NULL,
[Scale] TINYINT NOT NULL
);
CREATE TABLE #expected
(
[ParameterName] NVARCHAR(128) NOT NULL,
[DataType] sysname NOT NULL,
[MaxLength] SMALLINTNOT NULL,
[Precision] TINYINT NOT NULL,
[Scale] TINYINT NOT NULL
);
INSERT INTO#expected
(
ParameterName,
DataType,
MaxLength,
Precision,
Scale
)
VALUES
___PARAMETERS___
----- ACT ----------------------------------------------------INSERT INTO#actual
(
ParameterName,
DataType,
MaxLength,
Precision,
Scale
)
SELECTpm.nameAS ParameterName,
t.nameAS DataType,
pm.max_lengthAS MaxLength,
pm.precisionAS [Precision],
pm.scaleAS Scale
FROM___DATABASE___.sys.parameters AS pm
INNER JOIN___DATABASE___.sys.procedures AS ps
ONpm.object_id=ps.object_idINNER JOIN___DATABASE___.sys.schemas AS s
ONs.schema_id=ps.schema_idINNER JOIN___DATABASE___.sys.types AS t
ONpm.system_type_id=t.system_type_idANDpm.user_type_id=t.user_type_idWHEREs.name='___SCHEMA___'ANDps.name='___NAME___';
----- ASSERT --------------------------------------------------- Assert to have the same values
EXEC tSQLt.AssertEqualsTable @Expected ='#expected', @Actual ='#actual';
END;
Out of the above scripts (there are others corresponding to all of the basic tests in the repo), only the DatabaseCollationTest.template seems to be being applied by the script. As this is the first script in the directory, I am wondering if the folder is being correctly iterated over?
I'd appreciate any assistance in getting this working :-)
The text was updated successfully, but these errors were encountered:
Hi,
First off, thanks for your amazing code and YouTube tutorials :-)
I have created a set of tests using your script for a single database / testclass and I am now looking to push this out to all of my other databases.
I have created a PowerShell script which uses your module to loop through the databases that I want see here (some values modified):
I have also copied and modifiied the templates found in
$projectroot\internal\templates
some examples below:DatabaseCollationTest.template
FunctionParameterTest.template
ProcedureParameterTest.template
Out of the above scripts (there are others corresponding to all of the basic tests in the repo), only the
DatabaseCollationTest.template
seems to be being applied by the script. As this is the first script in the directory, I am wondering if the folder is being correctly iterated over?I'd appreciate any assistance in getting this working :-)
The text was updated successfully, but these errors were encountered: