(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestReadFile(t *testing.T) { |
| 55 | tests := []struct { |
| 56 | name string |
| 57 | filePath string |
| 58 | providers getter.Providers |
| 59 | setupFunc func(*testing.T) (string, func()) // setup temp files, return cleanup |
| 60 | expectError bool |
| 61 | expectStdin bool |
| 62 | expectedData []byte |
| 63 | }{ |
| 64 | { |
| 65 | name: "stdin input with dash", |
| 66 | filePath: "-", |
| 67 | providers: getter.Providers{}, |
| 68 | expectStdin: true, |
| 69 | expectError: false, |
| 70 | }, |
| 71 | { |
| 72 | name: "stdin input with whitespace", |
| 73 | filePath: " - ", |
| 74 | providers: getter.Providers{}, |
| 75 | expectStdin: true, |
| 76 | expectError: false, |
| 77 | }, |
| 78 | { |
| 79 | name: "invalid URL parsing", |
| 80 | filePath: "://invalid-url", |
| 81 | providers: getter.Providers{}, |
| 82 | expectError: true, |
| 83 | }, |
| 84 | { |
| 85 | name: "local file - existing", |
| 86 | filePath: "test.txt", |
| 87 | providers: getter.Providers{}, |
| 88 | setupFunc: func(t *testing.T) (string, func()) { |
| 89 | t.Helper() |
| 90 | tmpDir := t.TempDir() |
| 91 | filePath := filepath.Join(tmpDir, "test.txt") |
| 92 | content := []byte("local file content") |
| 93 | err := os.WriteFile(filePath, content, 0644) |
| 94 | if err != nil { |
| 95 | t.Fatal(err) |
| 96 | } |
| 97 | return filePath, func() {} // cleanup handled by t.TempDir() |
| 98 | }, |
| 99 | expectError: false, |
| 100 | expectedData: []byte("local file content"), |
| 101 | }, |
| 102 | { |
| 103 | name: "local file - non-existent", |
| 104 | filePath: "/non/existent/file.txt", |
| 105 | providers: getter.Providers{}, |
| 106 | expectError: true, |
| 107 | }, |
| 108 | { |
| 109 | name: "remote file with http scheme - success", |
| 110 | filePath: "http://example.com/values.yaml", |
| 111 | providers: getter.Providers{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…