MCPcopy
hub / github.com/jesseduffield/lazygit / TestOSCommandFileType

Function TestOSCommandFileType

pkg/commands/oscommands/os_test.go:83–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestOSCommandFileType(t *testing.T) {
84 type scenario struct {
85 path string
86 setup func()
87 test func(string)
88 }
89
90 scenarios := []scenario{
91 {
92 "testFile",
93 func() {
94 f, err := os.Create("testFile")
95 if err != nil {
96 panic(err)
97 }
98 if err := f.Close(); err != nil {
99 panic(err)
100 }
101 },
102 func(output string) {
103 assert.EqualValues(t, "file", output)
104 },
105 },
106 {
107 "file with spaces",
108 func() {
109 f, err := os.Create("file with spaces")
110 if err != nil {
111 panic(err)
112 }
113 if err := f.Close(); err != nil {
114 panic(err)
115 }
116 },
117 func(output string) {
118 assert.EqualValues(t, "file", output)
119 },
120 },
121 {
122 "testDirectory",
123 func() {
124 if err := os.Mkdir("testDirectory", 0o644); err != nil {
125 panic(err)
126 }
127 },
128 func(output string) {
129 assert.EqualValues(t, "directory", output)
130 },
131 },
132 {
133 "nonExistent",
134 func() {},
135 func(output string) {
136 assert.EqualValues(t, "other", output)
137 },
138 },
139 }
140

Callers

nothing calls this directly

Calls 4

FileTypeFunction · 0.85
testMethod · 0.80
CreateMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected