Skip to content

Commit b6c60a5

Browse files
Copilotmpscholten
andauthored
Fix test duplication in IHP tests (#2195)
* Initial plan * Changes before error encountered Co-authored-by: mpscholten <[email protected]> * Update table helper to take name as parameter for cleaner syntax Co-authored-by: mpscholten <[email protected]> * Apply col and table helpers to all test files (ParserSpec, SchemaOperationsSpec, SchemaCompilerSpec) Co-authored-by: mpscholten <[email protected]> * Apply col and table helpers to CodeGeneration test files Co-authored-by: mpscholten <[email protected]> * Update col helper to take columnName and columnType as parameters Co-authored-by: mpscholten <[email protected]> * Fix remaining col usages that were missed in ParserSpec Co-authored-by: mpscholten <[email protected]> * Fix formatting in ControllerGenerator.hs - move commas to start of continuation lines Co-authored-by: mpscholten <[email protected]> * Fix PArray type constructor usage - add missing parentheses Co-authored-by: mpscholten <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mpscholten <[email protected]>
1 parent fa613c5 commit b6c60a5

File tree

7 files changed

+186
-514
lines changed

7 files changed

+186
-514
lines changed

ihp-ide/Test/IDE/CodeGeneration/ControllerGenerator.hs

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,24 @@ import qualified Text.Megaparsec as Megaparsec
1212
import IHP.IDE.CodeGen.Types
1313
import IHP.IDE.SchemaDesigner.Types
1414
import IHP.NameSupport
15+
import Test.IDE.SchemaDesigner.ParserSpec (col, table)
1516

1617
tests = do
1718
describe "Controller Generator Tests:" do
1819
let schema = [
19-
StatementCreateTable CreateTable {
20-
name = "pages"
21-
, columns = [
22-
Column
23-
{ name = "id"
24-
, columnType = PUUID
25-
, defaultValue = Just (CallExpression "uuid_generate_v4" [])
26-
, notNull = True
27-
, isUnique = False
28-
, generator = Nothing
29-
}
20+
StatementCreateTable (table "pages") {
21+
columns = [
22+
(col "id" PUUID) { defaultValue = Just (CallExpression "uuid_generate_v4" []), notNull = True }
3023
]
3124
, primaryKeyConstraint = PrimaryKeyConstraint ["id"]
32-
, constraints = []
33-
, unlogged = False
3425
},
35-
StatementCreateTable CreateTable {
36-
name = "people"
37-
, columns = [
38-
Column
39-
{ name = "id"
40-
, columnType = PUUID
41-
, defaultValue = Just (CallExpression "uuid_generate_v4" [])
42-
, notNull = True
43-
, isUnique = False
44-
, generator = Nothing
45-
}
46-
,
47-
Column
48-
{ name = "name"
49-
, columnType = PText
50-
, defaultValue = Nothing
51-
, notNull = True
52-
, isUnique = False
53-
, generator = Nothing
54-
}
55-
,
56-
Column
57-
{ name = "email"
58-
, columnType = PText
59-
, defaultValue = Nothing
60-
, notNull = True
61-
, isUnique = False
62-
, generator = Nothing
63-
}
26+
StatementCreateTable (table "people") {
27+
columns = [
28+
(col "id" PUUID) { defaultValue = Just (CallExpression "uuid_generate_v4" []), notNull = True }
29+
, (col "name" PText) { notNull = True }
30+
, (col "email" PText) { notNull = True }
6431
]
6532
, primaryKeyConstraint = PrimaryKeyConstraint ["id"]
66-
, constraints = []
67-
, unlogged = False
6833
}
6934
]
7035

ihp-ide/Test/IDE/CodeGeneration/MailGenerator.hs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@ import qualified Text.Megaparsec as Megaparsec
1212
import IHP.IDE.CodeGen.Types
1313
import IHP.IDE.SchemaDesigner.Types
1414
import IHP.NameSupport
15+
import Test.IDE.SchemaDesigner.ParserSpec (col, table)
1516

1617

1718
tests = do
1819
describe "Mail Generator Tests:" do
1920
let schema = [
20-
StatementCreateTable CreateTable {
21-
name = "users"
22-
, columns = [
23-
Column
24-
{ name = "id"
25-
, columnType = PUUID
26-
, defaultValue = Just (CallExpression "uuid_generate_v4" [])
27-
, notNull = True
28-
, isUnique = False
29-
, generator = Nothing
30-
}
21+
StatementCreateTable (table "users") {
22+
columns = [
23+
(col "id" PUUID) { defaultValue = Just (CallExpression "uuid_generate_v4" []), notNull = True }
3124
]
3225
, primaryKeyConstraint = PrimaryKeyConstraint ["id"]
33-
, constraints = []
34-
, unlogged = False
3526
}
3627
]
3728
it "should build a mail with name \"PurchaseConfirmationMail\"" do

ihp-ide/Test/IDE/CodeGeneration/ViewGenerator.hs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@ import qualified Text.Megaparsec as Megaparsec
1212
import IHP.IDE.CodeGen.Types
1313
import IHP.IDE.SchemaDesigner.Types
1414
import IHP.NameSupport
15+
import Test.IDE.SchemaDesigner.ParserSpec (col, table)
1516

1617

1718
tests = do
1819
describe "View Generator Tests:" do
1920
let schema = [
20-
StatementCreateTable CreateTable {
21-
name = "pages"
22-
, columns = [
23-
Column
24-
{ name = "id"
25-
, columnType = PUUID
26-
, defaultValue = Just (CallExpression "uuid_generate_v4" [])
27-
, notNull = True
28-
, isUnique = False
29-
, generator = Nothing
30-
}
21+
StatementCreateTable (table "pages") {
22+
columns = [
23+
(col "id" PUUID) { defaultValue = Just (CallExpression "uuid_generate_v4" []), notNull = True }
3124
]
3225
, primaryKeyConstraint = PrimaryKeyConstraint ["id"]
33-
, constraints = []
34-
, unlogged = False
3526
}
3627
]
3728
it "should build a view with name \"EditView\"" do

0 commit comments

Comments
 (0)