Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
{
"name": "Docker in Docker",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
//"image": "mcr.microsoft.com/devcontainers/base:bullseye",
//"image": "mcr.microsoft.com/mssql/server:2022-latest",
// "image": "mcr.microsoft.com/devcontainers/base:bullseye",
"build": {
// Path is relataive to the devcontainer.json file.
"dockerfile": "Dockerfile"
},

"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
},
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/dotnet:1": {},
"ghcr.io/devcontainers/features/git:1": {},
// "ghcr.io/devcontainers/features/git-lfs:1": {},
// "ghcr.io/devcontainers/features/github-cli:1": {},
// "ghcr.io/devcontainers/features/go:1": {},
// "ghcr.io/devcontainers/features/powershell:1": {},
// "ghcr.io/devcontainers/features/python:1": {},
},

// Use this environment variable if you need to bind mount your local source code into a new container.
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],

"customizations": {
"vscode": {
"settings": {
"remote.autoForwardPorts": false
},
"extensions": [
"ms-mssql.mssql",
"redhat.vscode-yaml",
"ms-vscode.powershell",
"ms-azuretools.vscode-docker",
"ms-mssql.sql-bindings-vscode",
"ms-mssql.sql-database-projects-vscode",
"ms-mssql.data-workspace-vscode",
"github.vscode-github-actions",
"ms-dotnettools.csdevkit",
"ms-vscode.powershell",
"ms-azuretools.vscode-bicep",
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": ["/bin/sh", "-c", "whoami && pwd && chmod 777 ./.devcontainer/postCreateCommand.sh && ./.devcontainer/postCreateCommand.sh"], //

// Use 'postStartCommand' to run commands after the container is created.
"postStartCommand": ["/bin/sh", "-c", "whoami && pwd && chmod 777 ./.devcontainer/postStartCommand.sh && ./.devcontainer/postStartCommand.sh"], //

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}


// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
{
"name": "Docker in Docker",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
//"image": "mcr.microsoft.com/devcontainers/base:bullseye",
//"image": "mcr.microsoft.com/mssql/server:2022-latest",
// "image": "mcr.microsoft.com/devcontainers/base:bullseye",
"build": {
// Path is relataive to the devcontainer.json file.
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
},
// "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/dotnet:1": {},
"ghcr.io/devcontainers/features/git:1": {},
// "ghcr.io/devcontainers/features/git-lfs:1": {},
// "ghcr.io/devcontainers/features/github-cli:1": {},
// "ghcr.io/devcontainers/features/go:1": {},
// "ghcr.io/devcontainers/features/powershell:1": {},
// "ghcr.io/devcontainers/features/python:1": {},
},
// Use this environment variable if you need to bind mount your local source code into a new container.
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [],
"customizations": {
"vscode": {
"settings": {
"remote.autoForwardPorts": false
},
"extensions": [
"ms-mssql.mssql",
"redhat.vscode-yaml",
"ms-vscode.powershell",
"ms-azuretools.vscode-docker",
"ms-mssql.sql-bindings-vscode",
"ms-mssql.sql-database-projects-vscode",
"ms-mssql.data-workspace-vscode",
"github.vscode-github-actions",
"ms-dotnettools.csdevkit",
"ms-vscode.powershell",
"ms-azuretools.vscode-bicep",
]
}
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": ["/bin/sh", "-c", "whoami && pwd && /bin/sh ./.devcontainer/postCreateCommand.sh"], //
// Use 'postStartCommand' to run commands after the container is created.
"postStartCommand": ["/bin/sh", "-c", "whoami && pwd && /bin/sh ./.devcontainer/postStartCommand.sh"], //
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
1 change: 0 additions & 1 deletion .devcontainer/sqlserver.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
sql_server:
image: mcr.microsoft.com/mssql/server:2022-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
/tSQLtCLR/OfficialSigningKey/KeyInfoC.txt

.vscode/settings.json
.devcontainer/devcontainer-lock.json
74 changes: 74 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Start SQL Server",
"type": "shell",
"command": "docker-compose -f '${workspaceFolder}/.devcontainer/sqlserver.yml' up -d && until sqlcmd -S localhost,1433 -U sa -P 'P@ssw0rd' -Q 'SELECT 1' -b > /dev/null 2>&1; do echo 'Waiting for SQL Server...'; sleep 2; done && echo 'SQL Server is ready'",
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false
}
},
{
"label": "Deploy: Build & Deploy tSQLt from Source",
"type": "shell",
"command": "& '${workspaceFolder}/Build/LocalBuild.ps1' -ServerName 'localhost,1433' -UserName 'sa' -Password (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force)",
"options": {
"shell": {
"executable": "pwsh",
"args": ["-Command"]
},
"cwd": "${workspaceFolder}/Build"
},
"dependsOn": ["Start SQL Server"],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Test: Run tSQLt Unit Tests",
"type": "shell",
"command": "& '${workspaceFolder}/Build/LocalValidate.ps1' -ServerName 'localhost,1433' -UserName 'sa' -Password (ConvertTo-SecureString 'P@ssw0rd' -AsPlainText -Force)",
"options": {
"shell": {
"executable": "pwsh",
"args": ["-Command"]
},
"cwd": "${workspaceFolder}/Build"
},
"dependsOn": ["Start SQL Server"],
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true
}
}
]
}
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,44 @@ It is compatible with SQL Server 2005 (service pack 2 required) and above on all

tSQLt allows you to implement unit tests in T-SQL. This is important as you do not have to switch between various tools to create your code and your unit tests. tSQLt also provides the following features to make it easier to create and manage unit tests:

* Tests are automatically run within transactions this keeps tests independent and reduces any cleanup work you need
* Tests can be grouped together within a schema allowing you to organize your tests and use common setup methods
* Output can be generated in plain text or XML making it easier to integrate with a continuous integration tool
* Tests are automatically run within transactions - this keeps tests independent and reduces any cleanup work you need
* Tests can be grouped together within a schema - allowing you to organize your tests and use common setup methods
* Output can be generated in plain text or XML - making it easier to integrate with a continuous integration tool

tSQLt is licensed under Apache 2.0 (https://github.com/tSQLt-org/tSQLt/blob/master/Build/License.txt)

---

## Development Setup

The recommended way to work on tSQLt is with the included dev container. It provides a fully configured environment with SQL Server 2022, PowerShell, mssql-tools, sqlpackage, mono, and all required VS Code extensions - no local installation needed beyond Docker and VS Code.

### Prerequisites

- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (or Docker Engine on Linux)
- [VS Code](https://code.visualstudio.com/) with the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)

### Starting the dev container

0. Install "Dev Containers" extension in VS Code
1. Open the repository folder in VS Code.
2. When prompted "Reopen in Container", click it - or open the Command Palette (`Ctrl+Shift+P`) and run **Dev Containers: Reopen in Container**.
3. VS Code will build the container image and start SQL Server 2022 automatically. The first build takes a few minutes.

Once the container is ready, SQL Server is accessible at `localhost,1433` with credentials `sa` / `P@ssw0rd`.

### Build and deploy from source

Run the **Deploy: Build & Deploy tSQLt from Source** task (`Ctrl+Shift+B`) or via the Command Palette:

```
Terminal > Run Build Task
```

### Run unit tests

Run the **Test: Run tSQLt Unit Tests** task via the Command Palette:

```
Terminal > Run Test Task
```