Skip to content

Commit 0f7bbfd

Browse files
Add failing test for phantom type fix
1 parent afef114 commit 0f7bbfd

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

test/Lamdera/Evergreen/TestMigrationGenerator.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ testMigrationGeneration scenario oldVersion newVersion = do
5959

6060
io $ atomicPutStrLn <$> Ext.Common.requireBinary "elm-format"
6161

62-
let root = "/Users/mario/dev/projects/lamdera-compiler/test/scenario-migration-generate"
62+
let root = "/Users/martinstewart/dev/projects/lamdera-compiler/test/scenario-migration-generate"
6363
typeCompares = zipWith3
6464
(\label local prod -> (label, T.unpack local, T.unpack prod))
6565
(Lamdera.Types.core)
@@ -81,7 +81,7 @@ testMigrationGeneration scenario oldVersion newVersion = do
8181
]
8282

8383
compilationStdout <- catchOutput $
84-
Lamdera.Compile.makeDev "/Users/mario/dev/projects/lamdera-compiler/test/scenario-migration-generate" filenames
84+
Lamdera.Compile.makeDev "/Users/martinstewart/dev/projects/lamdera-compiler/test/scenario-migration-generate" filenames
8585

8686
compilationStdout `expectTextContains`
8787
"This `Unimplemented` value is a:\n\n UnimplementedMigration"
@@ -105,7 +105,7 @@ testExamples :: Test ()
105105
testExamples = withTestEnv $ do
106106
failuresM <- io $ newMVar []
107107
let
108-
project = "/Users/mario/dev/projects/lamdera-compiler/test/scenario-migration-generate"
108+
project = "/Users/martinstewart/dev/projects/lamdera-compiler/test/scenario-migration-generate"
109109
testFiles =
110110
[
111111
-- "src/Test/Migrate_Record.elm"

test/Test.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,13 @@ liveReloadLive = do
278278
-- "src/Bytes/Encode.elm"
279279
-- "withDebug"
280280

281-
target = EasyTest.run Test.WebGL.suite
282-
281+
target =
282+
EasyTest.run
283+
(tests
284+
[ scope "Lamdera.Evergreen.TestMigrationHarness -> " $ Lamdera.Evergreen.TestMigrationHarness.suite
285+
, scope "Lamdera.Evergreen.TestMigrationGenerator -> " $ Lamdera.Evergreen.TestMigrationGenerator.suite
286+
]
287+
)
283288
all =
284289
EasyTest.run allTests
285290

test/scenario-migration-generate/src/Migrate_All/Actual.elm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ migrate_Migrate_All_New_BackendModel old =
181181
, url = old.url
182182
, userCache = old.userCache |> migrate_AssocList_Dict identity migrate_IncludedBySpecialCasedParam_Custom
183183
, apps = (Unimplemented {- Type `Dict (String) (Migrate_All.New.App)` was added in V2. I need you to set a default value. -})
184+
, id = old.id |> migrate_Migrate_All_New_Id migrate_Migrate_All_New_UserId
184185
, depthTests = (Unimplemented {- Field of type `Dict (String) (Migrate_All.Old.Depth)` was removed in V2. I need you to do something with the `old.depthTests` value if you wish to keep the data, then remove this line. -})
185186
, removed = (Unimplemented {- Field of type `String` was removed in V2. I need you to do something with the `old.removed` value if you wish to keep the data, then remove this line. -})
186187
, removedRecord = (Unimplemented {- Field of type `Evergreen.V1.External.AllCoreTypes` was removed in V2. I need you to do something with the `old.removedRecord` value if you wish to keep the data, then remove this line. -})
@@ -197,6 +198,20 @@ migrate_Migrate_All_New_CustomType old =
197198
Migrate_All.New.CustomTwo
198199

199200

201+
migrate_Migrate_All_New_Id : (a_old -> a_new) -> Migrate_All.Old.Id a_old -> Migrate_All.New.Id a_new
202+
migrate_Migrate_All_New_Id migrate_a old =
203+
case old of
204+
Migrate_All.Old.Id p0 ->
205+
Migrate_All.New.Id p0
206+
207+
208+
migrate_Migrate_All_New_UserId : Migrate_All.Old.UserId -> Migrate_All.New.UserId
209+
migrate_Migrate_All_New_UserId old =
210+
case old of
211+
Migrate_All.Old.UserId ->
212+
Migrate_All.New.UserId
213+
214+
200215
migrate_Migrate_All_New_UserType : Migrate_All.Old.UserType -> Migrate_All.New.UserType
201216
migrate_Migrate_All_New_UserType old =
202217
case old of

test/scenario-migration-generate/src/Migrate_All/Expected.elm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ migrate_Migrate_All_New_BackendModel old =
181181
, url = old.url
182182
, userCache = old.userCache |> migrate_AssocList_Dict identity migrate_IncludedBySpecialCasedParam_Custom
183183
, apps = (Unimplemented {- Type `Dict (String) (Migrate_All.New.App)` was added in V2. I need you to set a default value. -})
184+
, id = old.id |> migrate_Migrate_All_New_Id
184185
, depthTests = (Unimplemented {- Field of type `Dict (String) (Migrate_All.Old.Depth)` was removed in V2. I need you to do something with the `old.depthTests` value if you wish to keep the data, then remove this line. -})
185186
, removed = (Unimplemented {- Field of type `String` was removed in V2. I need you to do something with the `old.removed` value if you wish to keep the data, then remove this line. -})
186187
, removedRecord = (Unimplemented {- Field of type `Evergreen.V1.External.AllCoreTypes` was removed in V2. I need you to do something with the `old.removedRecord` value if you wish to keep the data, then remove this line. -})
@@ -197,6 +198,14 @@ migrate_Migrate_All_New_CustomType old =
197198
Migrate_All.New.CustomTwo
198199

199200

201+
migrate_Migrate_All_New_Id : Migrate_All.Old.Id a_old -> Migrate_All.New.Id a_new
202+
migrate_Migrate_All_New_Id old =
203+
case old of
204+
Migrate_All.Old.Id p0 ->
205+
Migrate_All.New.Id p0
206+
207+
208+
200209
migrate_Migrate_All_New_UserType : Migrate_All.Old.UserType -> Migrate_All.New.UserType
201210
migrate_Migrate_All_New_UserType old =
202211
case old of

test/scenario-migration-generate/src/Migrate_All/New.elm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ type alias BackendModel =
5656

5757
-- WIP
5858
, apps : Dict String App
59+
60+
-- Phantom type
61+
, id : Id UserId
5962
}
6063

6164

@@ -144,3 +147,11 @@ type alias ConfigUses =
144147

145148
type alias ConfigUse =
146149
( String, String, List String )
150+
151+
152+
type Id a =
153+
Id String
154+
155+
156+
type UserId =
157+
UserId

test/scenario-migration-generate/src/Migrate_All/Old.elm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ type alias BackendModel =
5757

5858
-- WIP
5959
, depthTests : Dict String Depth
60+
61+
-- Phantom type
62+
, id : Id UserId
6063
}
6164

6265

@@ -154,3 +157,11 @@ type UnionThatGetsMoved
154157

155158
type alias AliasThatGetsMoved =
156159
{ someThing : String }
160+
161+
162+
type Id a =
163+
Id String
164+
165+
166+
type UserId =
167+
UserId

0 commit comments

Comments
 (0)