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
Removed extra quotes from AntTarget default value (all); updated tSQLt.Private_MarktSQLtTempObject.ssp.sql to allow only BIT type for IsTempObject value; Finished UndoTestDoubles code and test.
Copy file name to clipboardExpand all lines: Source/tSQLt.UndoTestDoubles.ssp.sql
+52-12Lines changed: 52 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -3,24 +3,41 @@ GO
3
3
---Build+
4
4
GO
5
5
CREATEPROCEDUREtSQLt.UndoTestDoubles
6
+
@Force BIT=0
6
7
AS
7
8
BEGIN
8
9
DECLARE @cmd NVARCHAR(MAX);
9
10
10
-
SELECT @cmd ='RAISERROR(''Cannot drop '+Collisions.List+' as it is not marked as temporary. Use @Force = 1 to override.'',16,10)'
11
+
IF (@Force =1)
12
+
BEGIN
13
+
SET @cmd ='EXEC tSQLt.Private_Print @Message = ''WARNING: @Force has been set to 1. Dropping the following objects that are not marked as temporary. (%s)'';';
14
+
END;
15
+
ELSE
16
+
BEGIN
17
+
SET @cmd ='RAISERROR(''Cannot drop these objects as they are not marked as temporary. Use @Force = 1 to override. (%s)'',16,10)';
CREATETABLEUndoTestDoublesTests.SimpleTable1 (i INT);
397
+
398
+
EXECtSQLt.ExpectException @ExpectedMessage ='Cannot drop these objects as they are not marked as temporary. Use @Force = 1 to override. ([UndoTestDoublesTests].[SimpleTable1])', @ExpectedSeverity =16, @ExpectedState =10;
399
+
400
+
EXECtSQLt.UndoTestDoubles;
398
401
END;
399
402
GO
400
-
CREATEPROCEDURE UndoTestDoublesTests.[test drops only objects that are marked as temporary (IsTempObject = 1)]
403
+
CREATEPROCEDURE UndoTestDoublesTests.[test does not drop multiple unmarked objects (IsTempObject is not set or is not 1)]
401
404
AS
402
405
BEGIN
403
406
CREATETABLEUndoTestDoublesTests.SimpleTable1 (i INT);
407
+
CREATETABLEUndoTestDoublesTests.SimpleTable2 (i INT);
408
+
CREATETABLEUndoTestDoublesTests.SimpleTable3 (i INT);
CREATETABLEUndoTestDoublesTests.SimpleTable1 (i INT);
415
+
CREATETABLEUndoTestDoublesTests.SimpleTable2 (i INT);
416
+
CREATETABLEUndoTestDoublesTests.SimpleTable3 (i INT);
407
417
408
-
EXECtSQLt.ExpectException @ExpectedMessage ='Cannot drop [UndoTestDoublesTests].[SimpleTable1] as it is not marked as temporary. Use @Force = 1 to override.', @ExpectedSeverity =16, @ExpectedState =10;
418
+
EXECtSQLt.ExpectException @ExpectedMessage ='Cannot drop these objects as they are not marked as temporary. Use @Force = 1 to override. ([UndoTestDoublesTests].[SimpleTable1], [UndoTestDoublesTests].[SimpleTable2], [UndoTestDoublesTests].[SimpleTable3])', @ExpectedSeverity =16, @ExpectedState =10;
409
419
410
420
EXECtSQLt.UndoTestDoubles;
421
+
END;
422
+
GO
423
+
CREATEPROCEDURE UndoTestDoublesTests.[test does not drop marked object where IsTempObject is not 1]
424
+
AS
425
+
BEGIN
426
+
CREATETABLEUndoTestDoublesTests.SimpleTable1 (i INT);
EXECtSQLt.ExpectException @ExpectedMessage ='Cannot drop these objects as they are not marked as temporary. Use @Force = 1 to override. ([UndoTestDoublesTests].[SimpleTable1])', @ExpectedSeverity =16, @ExpectedState =10;
437
+
438
+
EXECtSQLt.UndoTestDoubles;
412
439
END;
413
440
GO
414
-
CREATEPROCEDURE UndoTestDoublesTests.[test can handle multiple unmarked objects (IsTempObject is not set or is not 1)]
441
+
CREATEPROCEDURE UndoTestDoublesTests.[test objects renamed by RemoveObject are restored and conflicting objects without IsTempObject property are deleted if @Force=1]
0 commit comments