MCPcopy Index your code
hub / github.com/jetify-com/devbox / TestOpenError

Function TestOpenError

internal/devconfig/config_test.go:52–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestOpenError(t *testing.T) {
53 t.Run("NotExist", func(t *testing.T) {
54 root, _, _ := mkNestedDirs(t)
55 if _, err := Init(root); err != nil {
56 t.Fatalf("Init(%q) error: %v", root, err)
57 }
58
59 path := filepath.Join(root, "notafile.json")
60 cfg, err := Open(path)
61 if err == nil {
62 t.Fatalf("Open(%q) = %q, want error", root, cfg.Root.AbsRootPath)
63 }
64 if !errors.Is(err, fs.ErrNotExist) {
65 t.Error("errors.Is(err, fs.ErrNotExist) = false, want true")
66 }
67 if errors.Is(err, ErrNotFound) {
68 t.Error("errors.Is(err, ErrNotFound) = true, want false")
69 }
70 })
71 t.Run("NotFound", func(t *testing.T) {
72 root, _, _ := mkNestedDirs(t)
73
74 cfg, err := Open(root)
75 if err == nil {
76 t.Fatalf("Open(%q) = %q, want error", root, cfg.Root.AbsRootPath)
77 }
78 if !errors.Is(err, ErrNotFound) {
79 t.Error("errors.Is(err, ErrNotFound) = false, want true")
80 }
81 })
82 t.Run("ParentNotFound", func(t *testing.T) {
83 root, child, _ := mkNestedDirs(t)
84 if _, err := Init(root); err != nil {
85 t.Fatalf("Init(%q) error: %v", root, err)
86 }
87
88 cfg, err := Open(child)
89 if err == nil {
90 t.Fatalf("Open(%q) = %q, want error", root, cfg.Root.AbsRootPath)
91 }
92 if !errors.Is(err, ErrNotFound) {
93 t.Error("errors.Is(err, ErrNotFound) = false, want true")
94 }
95 })
96}
97
98func TestFind(t *testing.T) {
99 t.Run("StartInSameDir", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

mkNestedDirsFunction · 0.85
InitFunction · 0.85
IsMethod · 0.80
OpenFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected