2022-08-03 13:53:19 +07:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
2022-08-26 19:08:52 +07:00
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
2022-08-03 13:53:19 +07:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/gruntwork-io/terratest/modules/docker"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestToolsContainer(t *testing.T) {
|
2022-08-26 19:08:52 +07:00
|
|
|
image := "nixos/nix"
|
2022-08-30 15:03:20 +07:00
|
|
|
projectRoot, err := filepath.Abs("../")
|
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
2022-08-26 19:08:52 +07:00
|
|
|
|
|
|
|
options := &docker.RunOptions{
|
|
|
|
Remove: true,
|
|
|
|
Volumes: []string{
|
|
|
|
fmt.Sprintf("%s:%s", projectRoot, projectRoot),
|
|
|
|
"homelab-tools-cache:/root/.cache",
|
|
|
|
"homelab-tools-nix:/nix",
|
|
|
|
},
|
|
|
|
OtherOptions: []string{
|
|
|
|
"--workdir", projectRoot,
|
|
|
|
},
|
|
|
|
Command: []string{
|
|
|
|
"nix-shell",
|
|
|
|
"--command", "exit",
|
|
|
|
},
|
2022-08-03 13:53:19 +07:00
|
|
|
}
|
|
|
|
|
2022-08-26 19:08:52 +07:00
|
|
|
docker.Run(t, image, options)
|
2022-08-03 13:53:19 +07:00
|
|
|
}
|