-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain_test.go
More file actions
42 lines (37 loc) · 1.28 KB
/
main_test.go
File metadata and controls
42 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"errors"
"os"
"strings"
"testing"
"github.com/mikoto2000/devcontainer.vim/v3/devcontainer"
"github.com/mikoto2000/devcontainer.vim/v3/tools"
"github.com/mikoto2000/devcontainer.vim/v3/util"
)
func TestCreateConfigFile(t *testing.T) {
_, binDir, _, configDirForDevcontainer, err := util.CreateCacheDirectory(func() (string, error) {
return "./test", nil
}, "resource")
if err != nil {
panic(err)
}
devcontainerPath, _, err := tools.InstallStartTools(tools.DefaultInstallerUseServices{}, binDir)
if err != nil {
t.Fatalf("Error installing start tools: %v", err)
}
workspaceFolder := "./test/project/TestCreateConfigFile"
configFilePath, err := devcontainer.CreateConfigFile(devcontainerPath, workspaceFolder, configDirForDevcontainer)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
t.Skipf("configuration file not found: %v", err)
}
if strings.Contains(err.Error(), "出力パースに失敗") || strings.Contains(err.Error(), "read-configuration` に失敗") {
t.Skipf("devcontainer CLI environment issue: %v", err)
}
t.Fatalf("error: %v", err)
}
want := "test/resource/config/devcontainer/6d0900e89898e089cf294371661aea37/devcontainer.json"
if want != configFilePath {
t.Fatalf("error: want %s, but got %s", want, configFilePath)
}
}