Skip to content

Commit

Permalink
Merge pull request #13 from Geims83/compareData
Browse files Browse the repository at this point in the history
Compare data
  • Loading branch information
gicastel authored Dec 28, 2022
2 parents 945855e + 46d0ece commit 9d3d87c
Show file tree
Hide file tree
Showing 13 changed files with 411 additions and 50 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
A simple, cross platform, command line tool to test MSSQL procedures without the needs of a SSDT project or custom procedures / assemblies.

Define your own YAML file with before / after scripts (inline or external text files), input parameters and you can verify:
- Result sets column names, column order, column types and row number
- Result sets column names, column types, row number and valiues
- Output parameters type and value
- Return code value
- Custom asserts in the form of a SQL query returning a scalar value
Expand Down Expand Up @@ -42,7 +42,7 @@ docker run --rm -t \
```

### Bundle container
This container contains ( ;-) ) Microsoft SQL Server 2019 *and* qest executables, so you can deploy the database and run tests in a pristine environment.
This container contains ( ;-) ) Microsoft SQL Server 2022 *and* qest executables, so you can deploy the database and run tests in a pristine environment.
You need to provide:
- the `dacpac` file of your database: the folder containing it wil be mounted on the `/db` container folder
- the YAML files: the folder containing them wil be mounted on the `/tests` container folder
Expand Down
2 changes: 1 addition & 1 deletion Taskfile_dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tasks:
build:
desc: build project
cmds:
- dotnet build ./src/qest/
- dotnet build -c Release ./src/qest/
build:binaries:
desc: build binaries
deps:
Expand Down
162 changes: 129 additions & 33 deletions docs/yamlSchema.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,164 @@
{
"$schema": "http://json-schema.org/draft-04/schema",

"definitions": {
"Test": {
"properties": {
"name": { "type": "string" },
"name": {
"type": "string"
},
"variables": {
"type": "object",
"additionalProperties": true
},
"before": { "$ref": "#/definitions/Scripts" },
"before": {
"$ref": "#/definitions/Scripts"
},
"steps": {
"type": "array",
"items": { "$ref": "#/definitions/TestStep" }
"items": {
"$ref": "#/definitions/TestStep"
}
},
"after": { "$ref": "#/definitions/Scripts" }
"after": {
"$ref": "#/definitions/Scripts"
}
},
"required": ["name", "steps"],
"required": [
"name",
"steps"
],
"additionalProperties": false
},
"TestStep": {
"properties": {
"name": { "type": "string" },
"command": { "$ref": "#/definitions/TestCommand" },
"results": { "$ref": "#/definitions/ResultGroup" },
"name": {
"type": "string"
},
"command": {
"$ref": "#/definitions/TestCommand"
},
"results": {
"$ref": "#/definitions/ResultGroup"
},
"asserts": {
"type": "array",
"items": { "$ref": "#/definitions/Assert" }
"items": {
"$ref": "#/definitions/Assert"
}
}
},
"required": ["name", "command", "results"],
"required": [
"name",
"command",
"results"
],
"additionalProperties": false
},
"TestCommand": {
"properties": {
"commandText": { "type": "string" },
"parameters": { "additionalProperties": true }
"commandText": {
"type": "string"
},
"parameters": {
"additionalProperties": true
}
},
"required": ["commandText"],
"required": [
"commandText"
],
"additionalProperties": false
},
"ResultGroup": {
"properties": {
"resultSets": {
"type": "array",
"items": { "$ref": "#/definitions/ResultSet" }
"items": {
"$ref": "#/definitions/ResultSet"
}
},
"outputParameters": {
"type": "array",
"items": { "$ref": "#/definitions/OutputParameter" }
"items": {
"$ref": "#/definitions/OutputParameter"
}
},
"returnCode": { "type": "number" }
"returnCode": {
"type": "number"
}
},
"additionalProperties": false
},
"ResultSet": {
"properties": {
"name": { "type": "string" },
"rowNumber": { "type": "number" },
"name": {
"type": "string"
},
"rowNumber": {
"type": "number"
},
"columns": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "$ref": "#/definitions/SqlDbType" }
"name": {
"type": "string"
},
"type": {
"$ref": "#/definitions/SqlDbType"
}
},
"required": ["name", "type"],
"required": [
"name",
"type"
],
"additionalProperties": false
}
},
"data": {
"$ref": "#/definitions/DataScript"
}
},
"required": ["name", "columns"],
"required": [
"name",
"columns"
],
"additionalProperties": false
},
"OutputParameter": {
"type": "object",
"properties": {
"name": { "type": "string" },
"type": { "$ref": "#/definitions/SqlDbType" },
"name": {
"type": "string"
},
"type": {
"$ref": "#/definitions/SqlDbType"
},
"value": {}
},
"required": ["name", "type", "value"],
"required": [
"name",
"type",
"value"
],
"additionalProperties": false
},
"Assert": {
"type": "object",
"properties": {
"sqlQuery": { "type": "string" },
"scalarType": { "$ref": "#/definitions/SqlDbType" },
"sqlQuery": {
"type": "string"
},
"scalarType": {
"$ref": "#/definitions/SqlDbType"
},
"scalarValue": {}
},
"required": ["sqlQuery", "scalarType", "scalarValue"],
"required": [
"sqlQuery",
"scalarType",
"scalarValue"
],
"additionalProperties": false
},
"Scripts": {
Expand All @@ -108,14 +175,44 @@
},
"values": {
"type": "array",
"items": { "type": "string" }
"items": {
"type": "string"
}
}
},
"additionalProperties": false
},
"DataScript": {
"type": "object",
"properties": {
"type": {
"$ref": "#/definitions/ScriptType"
},
"values": {
"type": "array",
"items": {
"type": "string"
}
},
"separator": {
"type": "string"
},
"skipField": {
"type": "string"
}
},
"required": [
"type",
"values"
],
"additionalProperties": false
},
"ScriptType": {
"type": "string",
"enum": ["File", "Inline"]
"enum": [
"File",
"Inline"
]
},
"SqlDbType": {
"type": "string",
Expand All @@ -138,10 +235,9 @@
]
}
},

"type": "array",
"items": {
"$ref": "#/definitions/Test"
},
"additionalProperties": false
}
}
3 changes: 2 additions & 1 deletion samples/sampleDb/dbo/Stored Procedures/SampleSP.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ BEGIN
[DateTime2Value],
[DateTimeOffsetValue],
[DateValue],
[Time]
[Time],
NULL AS [NullValue]
FROM dbo.SampleTable
WHERE [Name] = @name

Expand Down
1 change: 1 addition & 0 deletions samples/scripts/results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{nameVar};True;*;7777;2;1210000000;3.14159265;1.1235813;21;0.00;1985-10-26 09:00:00.000;2015-10-21 07:28:00.0000000;1955-11-12 06:38:00.0000000 +00:00;1900-01-01;09:40:00;
66 changes: 65 additions & 1 deletion samples/tests/sampleSp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
type: Date
- name: TimeValue
type: Time
- name: NullValue
type: Int
data:
type: Inline
values:
- "SampleName;True;42;*"
outputParameters:
- name: oldValue
type: Int
Expand All @@ -60,6 +66,64 @@
- sqlQuery: SELECT COUNT(*) FROM dbo.SampleTable WHERE [IntValue] = {newValueVar}
scalarType: Int
scalarValue: 1
- name: Test OK with csv data
command:
commandText: dbo.SampleSp
parameters:
name: "{nameVar}"
newValue: 2
results:
resultSets:
- name: sampleSpRS1
rowNumber: 1
columns:
- name: Name
type: NVarChar
- name: BitValue
type: Bit
- name: TinyIntValue
type: TinyInt
- name: SmallintValue
type: SmallInt
- name: IntValue
type: Int
- name: BigIntValue
type: BigInt
- name: FloatValue
type: Float
- name: RealtValue
type: Real
- name: DecimalValue
type: Decimal
- name: MoneyValue
type: Money
- name: DateTimeValue
type: DateTime
- name: DateTime2Value
type: DateTime2
- name: DateTimeOffsetValue
type: DateTimeOffset
- name: DateValue
type: Date
- name: TimeValue
type: Time
- name: NullValue
type: Int
data:
type: File
values:
- scripts/results.csv
separator: ";"
skipField: "*"
outputParameters:
- name: oldValue
type: Int
value: 1
returnCode: 0
asserts:
- sqlQuery: SELECT COUNT(*) FROM dbo.SampleTable WHERE [IntValue] = 2
scalarType: Int
scalarValue: 1
- name: Test KO
command:
commandText: dbo.SampleSp
Expand Down Expand Up @@ -107,7 +171,7 @@
commandText: dbo.SampleSp
parameters:
name: "NoMatchData"
newValue: a
newValue: NULL
results:
returnCode: 0
after:
Expand Down
5 changes: 5 additions & 0 deletions src/qest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "qest", "qest\qest.csproj", "{79EF488B-B5FE-4DEE-807E-51CA359318C9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{78937758-7B07-465D-A4CA-FE5DB8F29435}"
ProjectSection(SolutionItems) = preProject
..\docs\yamlSchema.json = ..\docs\yamlSchema.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
Loading

0 comments on commit 9d3d87c

Please sign in to comment.