@@ -41,7 +41,9 @@ public void Invoke()
4141 -Path $Path `
4242 -Confirm: $false
4343
44- Get-SqlMigrations -Target $TargetA
44+ # Test pipeline input
45+ $TargetA | Get-SqlMigrations
46+ [PSql.Deploy.SqlTargetDatabase]::new($TargetA) | Get-SqlMigrations
4547 """
4648 ) ;
4749
@@ -51,33 +53,29 @@ public void Invoke()
5153
5254 var migrations = output . Select ( o => o ? . BaseObject ) . OfType < Migration > ( ) . ToList ( ) ;
5355
54- migrations . Count . ShouldBe ( 6 ) ;
55-
56- // From Pre+Core run
57- migrations [ 0 ] . Name . ShouldBe ( "Migration0" ) ;
58- migrations [ 0 ] . Hash . ShouldBe ( "D8462C316FD72659FB11FA7C9727D05707F8332B" ) ;
59- migrations [ 0 ] . State . ShouldBe ( MigrationState . AppliedCore ) ;
56+ migrations . Count . ShouldBe ( 9 ) ;
6057
61- migrations [ 1 ] . Name . ShouldBe ( "Migration1" ) ;
62- migrations [ 1 ] . Hash . ShouldBe ( "2909F7C67C9B831FFCD4655F31683941F700A205" ) ;
63- migrations [ 1 ] . State . ShouldBe ( MigrationState . AppliedCore ) ;
58+ void ShouldBeMigrations ( int n , MigrationState state )
59+ {
60+ migrations [ n + 0 ] . Name . ShouldBe ( "Migration0" ) ;
61+ migrations [ n + 0 ] . Hash . ShouldBe ( "D8462C316FD72659FB11FA7C9727D05707F8332B" ) ;
62+ migrations [ n + 0 ] . State . ShouldBe ( state ) ;
6463
65- migrations [ 2 ] . Name . ShouldBe ( "Migration2 " ) ;
66- migrations [ 2 ] . Hash . ShouldBe ( "FB049E6EA9DC10019088850C94E9C5D2661A6DE7 " ) ;
67- migrations [ 2 ] . State . ShouldBe ( MigrationState . AppliedCore ) ;
64+ migrations [ n + 1 ] . Name . ShouldBe ( "Migration1 " ) ;
65+ migrations [ n + 1 ] . Hash . ShouldBe ( "2909F7C67C9B831FFCD4655F31683941F700A205 " ) ;
66+ migrations [ n + 1 ] . State . ShouldBe ( state ) ;
6867
69- // From Post run
70- migrations [ 3 ] . Name . ShouldBe ( "Migration0 " ) ;
71- migrations [ 3 ] . Hash . ShouldBe ( "D8462C316FD72659FB11FA7C9727D05707F8332B" ) ;
72- migrations [ 3 ] . State . ShouldBe ( MigrationState . AppliedPost ) ;
68+ migrations [ n + 2 ] . Name . ShouldBe ( "Migration2" ) ;
69+ migrations [ n + 2 ] . Hash . ShouldBe ( "FB049E6EA9DC10019088850C94E9C5D2661A6DE7 " ) ;
70+ migrations [ n + 2 ] . State . ShouldBe ( state ) ;
71+ }
7372
74- migrations [ 4 ] . Name . ShouldBe ( "Migration1" ) ;
75- migrations [ 4 ] . Hash . ShouldBe ( "2909F7C67C9B831FFCD4655F31683941F700A205" ) ;
76- migrations [ 4 ] . State . ShouldBe ( MigrationState . AppliedPost ) ;
73+ // From Pre+Core run
74+ ShouldBeMigrations ( 0 , MigrationState . AppliedCore ) ;
7775
78- migrations [ 5 ] . Name . ShouldBe ( "Migration2" ) ;
79- migrations [ 5 ] . Hash . ShouldBe ( "FB049E6EA9DC10019088850C94E9C5D2661A6DE7" ) ;
80- migrations [ 5 ] . State . ShouldBe ( MigrationState . AppliedPost ) ;
76+ // From Post run
77+ ShouldBeMigrations ( 3 , MigrationState . AppliedPost ) ;
78+ ShouldBeMigrations ( 6 , MigrationState . AppliedPost ) ;
8179
8280 File . ReadAllText ( "..PSqlDeployTestA.0_Pre.log" ) . ShouldNotBeNullOrEmpty ( ) ;
8381 File . ReadAllText ( "..PSqlDeployTestA.1_Core.log" ) . ShouldNotBeNullOrEmpty ( ) ;
0 commit comments