MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestFormatter_NonExistentFile

Function TestFormatter_NonExistentFile

cmd/gosqlx/cmd/formatter_test.go:289–309  ·  view source on GitHub ↗

TestFormatter_NonExistentFile tests handling of non-existent files

(t *testing.T)

Source from the content-addressed store, hash-verified

287
288// TestFormatter_NonExistentFile tests handling of non-existent files
289func TestFormatter_NonExistentFile(t *testing.T) {
290 var outBuf, errBuf bytes.Buffer
291 formatter := NewFormatter(&outBuf, &errBuf, CLIFormatterOptions{
292 IndentSize: 2,
293 Uppercase: true,
294 })
295
296 result := formatter.formatFile("/nonexistent/file.sql")
297
298 if result.Error == nil {
299 t.Error("Expected error for non-existent file")
300 }
301
302 if result.Changed {
303 t.Error("Expected changed=false for non-existent file")
304 }
305
306 if !strings.Contains(result.Error.Error(), "file access validation failed") {
307 t.Errorf("Expected 'file access validation failed' error, got: %v", result.Error)
308 }
309}
310
311// TestFormatter_EmptyArgs tests handling of empty file arguments
312func TestFormatter_EmptyArgs(t *testing.T) {

Callers

nothing calls this directly

Calls 4

formatFileMethod · 0.95
NewFormatterFunction · 0.70
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected